<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The GRASP/AQUA Project, Glasgow University, 1992-2006

GHC.Rename.Env contains functions which convert RdrNames into Names.

-}</span><span>
</span><span id="line-7"></span><span>
</span><span id="line-8"></span><span class="hs-pragma">{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns #-}</span><span>
</span><span id="line-9"></span><span>
</span><span id="line-10"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Rename.Env</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-11"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#newTopSrcBinder"><span class="hs-identifier">newTopSrcBinder</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-12"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocatedTopBndrRn"><span class="hs-identifier">lookupLocatedTopBndrRn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupTopBndrRn"><span class="hs-identifier">lookupTopBndrRn</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-13"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocatedOccRn"><span class="hs-identifier">lookupLocatedOccRn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupOccRn"><span class="hs-identifier">lookupOccRn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupOccRn_maybe"><span class="hs-identifier">lookupOccRn_maybe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocalOccRn_maybe"><span class="hs-identifier">lookupLocalOccRn_maybe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupInfoOccRn"><span class="hs-identifier">lookupInfoOccRn</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocalOccThLvl_maybe"><span class="hs-identifier">lookupLocalOccThLvl_maybe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocalOccRn"><span class="hs-identifier">lookupLocalOccRn</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupTypeOccRn"><span class="hs-identifier">lookupTypeOccRn</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupGlobalOccRn"><span class="hs-identifier">lookupGlobalOccRn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupGlobalOccRn_maybe"><span class="hs-identifier">lookupGlobalOccRn_maybe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupOccRn_overloaded"><span class="hs-identifier">lookupOccRn_overloaded</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupGlobalOccRn_overloaded"><span class="hs-identifier">lookupGlobalOccRn_overloaded</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#ChildLookupResult"><span class="hs-identifier">ChildLookupResult</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupSubBndrOcc_helper"><span class="hs-identifier">lookupSubBndrOcc_helper</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#combineChildLookupResult"><span class="hs-identifier">combineChildLookupResult</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- Called by lookupChildrenExport</span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#HsSigCtxt"><span class="hs-identifier">HsSigCtxt</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocalTcNames"><span class="hs-identifier">lookupLocalTcNames</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupSigOccRn"><span class="hs-identifier">lookupSigOccRn</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupSigCtxtOccRn"><span class="hs-identifier">lookupSigCtxtOccRn</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupInstDeclBndr"><span class="hs-identifier">lookupInstDeclBndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupRecFieldOcc"><span class="hs-identifier">lookupRecFieldOcc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupFamInstName"><span class="hs-identifier">lookupFamInstName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupConstructorFields"><span class="hs-identifier">lookupConstructorFields</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupGreAvailRn"><span class="hs-identifier">lookupGreAvailRn</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span>        </span><span class="hs-comment">-- Rebindable Syntax</span><span>
</span><span id="line-33"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupSyntax"><span class="hs-identifier">lookupSyntax</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupSyntaxExpr"><span class="hs-identifier">lookupSyntaxExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupSyntaxName"><span class="hs-identifier">lookupSyntaxName</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupSyntaxNames"><span class="hs-identifier">lookupSyntaxNames</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupIfThenElse"><span class="hs-identifier">lookupIfThenElse</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupReboundIf"><span class="hs-identifier">lookupReboundIf</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span>        </span><span class="hs-comment">-- QualifiedDo</span><span>
</span><span id="line-37"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupQualifiedDoExpr"><span class="hs-identifier">lookupQualifiedDoExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupQualifiedDo"><span class="hs-identifier">lookupQualifiedDo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#lookupQualifiedDoName"><span class="hs-identifier">lookupQualifiedDoName</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#lookupNameWithQualifier"><span class="hs-identifier">lookupNameWithQualifier</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span>        </span><span class="hs-comment">-- Constructing usage information</span><span>
</span><span id="line-41"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#addUsedGRE"><span class="hs-identifier">addUsedGRE</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#addUsedGREs"><span class="hs-identifier">addUsedGREs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#addUsedDataCons"><span class="hs-identifier">addUsedDataCons</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#dataTcOccs"><span class="hs-identifier">dataTcOccs</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-comment">--TODO: Move this somewhere, into utils?</span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Iface.Load.html"><span class="hs-identifier">GHC.Iface.Load</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Iface.Load.html#loadInterfaceForName"><span class="hs-identifier">loadInterfaceForName</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Iface.Load.html#loadSrcInterface_maybe"><span class="hs-identifier">loadSrcInterface_maybe</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Iface.Env.html"><span class="hs-identifier">GHC.Iface.Env</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Hs.html"><span class="hs-identifier">GHC.Hs</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html"><span class="hs-identifier">GHC.Types.Name.Reader</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html"><span class="hs-identifier">GHC.Driver.Types</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html"><span class="hs-identifier">GHC.Tc.Utils.Env</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Parser.PostProcess.html"><span class="hs-identifier">GHC.Parser.PostProcess</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Parser.PostProcess.html#filterCTuple"><span class="hs-identifier">filterCTuple</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Parser.PostProcess.html#setRdrNameSpace"><span class="hs-identifier">setRdrNameSpace</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.RebindableNames.html"><span class="hs-identifier">GHC.Builtin.RebindableNames</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html"><span class="hs-identifier">GHC.Types.Name.Set</span></a></span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Env.html"><span class="hs-identifier">GHC.Types.Name.Env</span></a></span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Avail.html"><span class="hs-identifier">GHC.Types.Avail</span></a></span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Unit.Module.html"><span class="hs-identifier">GHC.Unit.Module</span></a></span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html"><span class="hs-identifier">GHC.Core.ConLike</span></a></span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier">MsgDoc</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html#rOOT_MAIN"><span class="hs-identifier">rOOT_MAIN</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#pprWarningTxtForMsg"><span class="hs-identifier">pprWarningTxtForMsg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier">TopLevelFlag</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TupleSort"><span class="hs-identifier">TupleSort</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-74"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html"><span class="hs-identifier">GHC.Types.SrcLoc</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">SrcLoc</span></span><span>
</span><span id="line-75"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Outputable</span></span><span>
</span><span id="line-76"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html"><span class="hs-identifier">GHC.Types.Unique.Set</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html#uniqSetAny"><span class="hs-identifier">uniqSetAny</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-77"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-78"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-79"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-80"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-81"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-82"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.List.SetOps.html"><span class="hs-identifier">GHC.Data.List.SetOps</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Data.List.SetOps.html#minusList"><span class="hs-identifier">minusList</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-83"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.LanguageExtensions.html#"><span class="hs-identifier">GHC.LanguageExtensions</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LangExt</span></span><span>
</span><span id="line-84"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Rename.Unbound.html"><span class="hs-identifier">GHC.Rename.Unbound</span></a></span><span>
</span><span id="line-85"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Rename.Utils.html"><span class="hs-identifier">GHC.Rename.Utils</span></a></span><span>
</span><span id="line-86"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Data.Semigroup.html#"><span class="hs-identifier">Data.Semigroup</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Semi</span></span><span>
</span><span id="line-87"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#"><span class="hs-identifier">Data.Either</span></a></span><span>      </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#partitionEithers"><span class="hs-identifier">partitionEithers</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-88"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#find"><span class="hs-identifier">find</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#sortBy"><span class="hs-identifier">sortBy</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Arrow.html#"><span class="hs-identifier">Control.Arrow</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Control.Arrow.html#first"><span class="hs-identifier">first</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-90"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Function.html#"><span class="hs-identifier">Data.Function</span></a></span><span>
</span><span id="line-91"></span><span>
</span><span id="line-92"></span><span class="hs-comment">{-
*********************************************************
*                                                      *
                Source-code binders
*                                                      *
*********************************************************

Note [Signature lazy interface loading]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

GHC's lazy interface loading can be a bit confusing, so this Note is an
empirical description of what happens in one interesting case. When
compiling a signature module against an its implementation, we do NOT
load interface files associated with its names until after the type
checking phase.  For example:

    module ASig where
        data T
        f :: T -&gt; T

Suppose we compile this with -sig-of &quot;A is ASig&quot;:

    module B where
        data T = T
        f T = T

    module A(module B) where
        import B

During type checking, we'll load A.hi because we need to know what the
RdrEnv for the module is, but we DO NOT load the interface for B.hi!
It's wholly unnecessary: our local definition 'data T' in ASig is all
the information we need to finish type checking.  This is contrast to
type checking of ordinary Haskell files, in which we would not have the
local definition &quot;data T&quot; and would need to consult B.hi immediately.
(Also, this situation never occurs for hs-boot files, since you're not
allowed to reexport from another module.)

After type checking, we then check that the types we provided are
consistent with the backing implementation (in checkHiBootOrHsigIface).
At this point, B.hi is loaded, because we need something to compare
against.

I discovered this behavior when trying to figure out why type class
instances for Data.Map weren't in the EPS when I was type checking a
test very much like ASig (sigof02dm): the associated interface hadn't
been loaded yet!  (The larger issue is a moot point, since an instance
declared in a signature can never be a duplicate.)

This behavior might change in the future.  Consider this
alternate module B:

    module B where
        {-# DEPRECATED T, f &quot;Don't use&quot; #-}
        data T = T
        f T = T

One might conceivably want to report deprecation warnings when compiling
ASig with -sig-of B, in which case we need to look at B.hi to find the
deprecation warnings during renaming.  At the moment, you don't get any
warning until you use the identifier further downstream.  This would
require adjusting addUsedGRE so that during signature compilation,
we do not report deprecation warnings for LocalDef.  See also
Note [Handling of deprecations]
-}</span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span class="annot"><a href="GHC.Rename.Env.html#newTopSrcBinder"><span class="hs-identifier hs-type">newTopSrcBinder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-159"></span><span id="newTopSrcBinder"><span class="annot"><span class="annottext">newTopSrcBinder :: Located RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#newTopSrcBinder"><span class="hs-identifier hs-var hs-var">newTopSrcBinder</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681107890"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681107890"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681107889"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107889"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-160"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107888"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107888"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; Maybe Name
</span><a href="GHC.Types.Name.Reader.html#isExact_maybe"><span class="hs-identifier hs-var">isExact_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107889"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-161"></span><span>  </span><span class="hs-glyph">=</span><span>     </span><span class="hs-comment">-- This is here to catch</span><span>
</span><span id="line-162"></span><span>        </span><span class="hs-comment">--   (a) Exact-name binders created by Template Haskell</span><span>
</span><span id="line-163"></span><span>        </span><span class="hs-comment">--   (b) The PrelBase defn of (say) [] and similar, for which</span><span>
</span><span id="line-164"></span><span>        </span><span class="hs-comment">--       the parser reads the special syntax and returns an Exact RdrName</span><span>
</span><span id="line-165"></span><span>        </span><span class="hs-comment">-- We are at a binding site for the name, so check first that it</span><span>
</span><span id="line-166"></span><span>        </span><span class="hs-comment">-- the current module is the correct one; otherwise GHC can get</span><span>
</span><span id="line-167"></span><span>        </span><span class="hs-comment">-- very confused indeed. This test rejects code like</span><span>
</span><span id="line-168"></span><span>        </span><span class="hs-comment">--      data T = (,) Int Int</span><span>
</span><span id="line-169"></span><span>        </span><span class="hs-comment">-- unless we are in GHC.Tup</span><span>
</span><span id="line-170"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isExternalName"><span class="hs-identifier hs-var">isExternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107888"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-171"></span><span>      </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107885"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107885"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-172"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107885"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">Module -&gt; Module -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Name -&gt; Module
Name -&gt; Module
</span><a href="GHC.Types.Name.html#nameModule"><span class="hs-identifier hs-var">nameModule</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107888"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-173"></span><span>                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrAt"><span class="hs-identifier hs-var">addErrAt</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681107890"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
</span><a href="GHC.Rename.Env.html#badOrigBinding"><span class="hs-identifier hs-var">badOrigBinding</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107889"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-174"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107888"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-175"></span><span>    </span><span class="hs-keyword">else</span><span>   </span><span class="hs-comment">-- See Note [Binders in Template Haskell] in &quot;GHC.ThToHs&quot;</span><span>
</span><span id="line-176"></span><span>      </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107879"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107879"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-177"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Module -&gt; Name -&gt; RnM Name
forall m n. Module -&gt; Name -&gt; TcRnIf m n Name
</span><a href="GHC.Iface.Env.html#externaliseName"><span class="hs-identifier hs-var">externaliseName</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107879"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107888"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-178"></span><span>
</span><span id="line-179"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681107877"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107877"><span class="hs-identifier hs-var">rdr_mod</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681107876"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107876"><span class="hs-identifier hs-var">rdr_occ</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; Maybe (Module, OccName)
</span><a href="GHC.Types.Name.Reader.html#isOrig_maybe"><span class="hs-identifier hs-var">isOrig_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107889"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-180"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107874"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107874"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-181"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107877"><span class="hs-identifier hs-var">rdr_mod</span></a></span><span> </span><span class="annot"><span class="annottext">Module -&gt; Module -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107874"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107877"><span class="hs-identifier hs-var">rdr_mod</span></a></span><span> </span><span class="annot"><span class="annottext">Module -&gt; Module -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="GHC.Builtin.Names.html#rOOT_MAIN"><span class="hs-identifier hs-var">rOOT_MAIN</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-182"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrAt"><span class="hs-identifier hs-var">addErrAt</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681107890"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
</span><a href="GHC.Rename.Env.html#badOrigBinding"><span class="hs-identifier hs-var">badOrigBinding</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107889"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-183"></span><span>        </span><span class="hs-comment">-- When reading External Core we get Orig names as binders,</span><span>
</span><span id="line-184"></span><span>        </span><span class="hs-comment">-- but they should agree with the module gotten from the monad</span><span>
</span><span id="line-185"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-186"></span><span>        </span><span class="hs-comment">-- We can get built-in syntax showing up here too, sadly.  If you type</span><span>
</span><span id="line-187"></span><span>        </span><span class="hs-comment">--      data T = (,,,)</span><span>
</span><span id="line-188"></span><span>        </span><span class="hs-comment">-- the constructor is parsed as a type, and then GHC.Parser.PostProcess.tyConToDataCon</span><span>
</span><span id="line-189"></span><span>        </span><span class="hs-comment">-- uses setRdrNameSpace to make it into a data constructors.  At that point</span><span>
</span><span id="line-190"></span><span>        </span><span class="hs-comment">-- the nice Exact name for the TyCon gets swizzled to an Orig name.</span><span>
</span><span id="line-191"></span><span>        </span><span class="hs-comment">-- Hence the badOrigBinding error message.</span><span>
</span><span id="line-192"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-193"></span><span>        </span><span class="hs-comment">-- Except for the &quot;:Main.main = ...&quot; definition inserted into</span><span>
</span><span id="line-194"></span><span>        </span><span class="hs-comment">-- the Main module; ugh!</span><span>
</span><span id="line-195"></span><span>
</span><span id="line-196"></span><span>        </span><span class="hs-comment">-- Because of this latter case, we call newGlobalBinder with a module from</span><span>
</span><span id="line-197"></span><span>        </span><span class="hs-comment">-- the RdrName, not from the environment.  In principle, it'd be fine to</span><span>
</span><span id="line-198"></span><span>        </span><span class="hs-comment">-- have an arbitrary mixture of external core definitions in a single module,</span><span>
</span><span id="line-199"></span><span>        </span><span class="hs-comment">-- (apart from module-initialisation issues, perhaps).</span><span>
</span><span id="line-200"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Module -&gt; OccName -&gt; SrcSpan -&gt; RnM Name
forall a b. Module -&gt; OccName -&gt; SrcSpan -&gt; TcRnIf a b Name
</span><a href="GHC.Iface.Env.html#newGlobalBinder"><span class="hs-identifier hs-var">newGlobalBinder</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107877"><span class="hs-identifier hs-var">rdr_mod</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107876"><span class="hs-identifier hs-var">rdr_occ</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681107890"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-203"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#isQual"><span class="hs-identifier hs-var">isQual</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107889"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-204"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrAt"><span class="hs-identifier hs-var">addErrAt</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681107890"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
</span><a href="GHC.Rename.Utils.html#badQualBndrErr"><span class="hs-identifier hs-var">badQualBndrErr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107889"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-205"></span><span>                </span><span class="hs-comment">-- Binders should not be qualified; if they are, and with a different</span><span>
</span><span id="line-206"></span><span>                </span><span class="hs-comment">-- module name, we get a confusing &quot;M.T is not in scope&quot; error later</span><span>
</span><span id="line-207"></span><span>
</span><span id="line-208"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681107868"><span class="annot"><span class="annottext">ThStage
</span><a href="#local-6989586621681107868"><span class="hs-identifier hs-var">stage</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM ThStage
</span><a href="GHC.Tc.Utils.Monad.html#getStage"><span class="hs-identifier hs-var">getStage</span></a></span><span>
</span><span id="line-209"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">ThStage -&gt; Bool
</span><a href="GHC.Tc.Utils.Env.html#isBrackStage"><span class="hs-identifier hs-var">isBrackStage</span></a></span><span> </span><span class="annot"><span class="annottext">ThStage
</span><a href="#local-6989586621681107868"><span class="hs-identifier hs-var">stage</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-210"></span><span>                </span><span class="hs-comment">-- We are inside a TH bracket, so make an *Internal* name</span><span>
</span><span id="line-211"></span><span>                </span><span class="hs-comment">-- See Note [Top-level Names in Template Haskell decl quotes] in GHC.Rename.Names</span><span>
</span><span id="line-212"></span><span>             </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107865"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681107865"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-213"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique -&gt; OccName -&gt; SrcSpan -&gt; Name
</span><a href="GHC.Types.Name.html#mkInternalName"><span class="hs-identifier hs-var">mkInternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681107865"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#rdrNameOcc"><span class="hs-identifier hs-var">rdrNameOcc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107889"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681107890"><span class="hs-identifier hs-var">loc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-214"></span><span>          </span><span class="hs-keyword">else</span><span>
</span><span id="line-215"></span><span>             </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107861"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107861"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-216"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;newTopSrcBinder&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107861"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107889"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681107890"><span class="hs-identifier hs-var">loc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-217"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Module -&gt; OccName -&gt; SrcSpan -&gt; RnM Name
forall a b. Module -&gt; OccName -&gt; SrcSpan -&gt; TcRnIf a b Name
</span><a href="GHC.Iface.Env.html#newGlobalBinder"><span class="hs-identifier hs-var">newGlobalBinder</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107861"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#rdrNameOcc"><span class="hs-identifier hs-var">rdrNameOcc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107889"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681107890"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-218"></span><span>        </span><span class="hs-special">}</span><span>
</span><span id="line-219"></span><span>
</span><span id="line-220"></span><span class="hs-comment">{-
*********************************************************
*                                                      *
        Source code occurrences
*                                                      *
*********************************************************

Looking up a name in the GHC.Rename.Env.

Note [Type and class operator definitions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We want to reject all of these unless we have -XTypeOperators (#3265)
   data a :*: b  = ...
   class a :*: b where ...
   data (:*:) a b  = ....
   class (:*:) a b where ...
The latter two mean that we are not just looking for a
*syntactically-infix* declaration, but one that uses an operator
OccName.  We use OccName.isSymOcc to detect that case, which isn't
terribly efficient, but there seems to be no better way.
-}</span><span>
</span><span id="line-241"></span><span>
</span><span id="line-242"></span><span class="hs-comment">-- Can be made to not be exposed</span><span>
</span><span id="line-243"></span><span class="hs-comment">-- Only used unwrapped in rnAnnProvenance</span><span>
</span><span id="line-244"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupTopBndrRn"><span class="hs-identifier hs-type">lookupTopBndrRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-245"></span><span class="hs-comment">-- Look up a top-level source-code binder.   We may be looking up an unqualified 'f',</span><span>
</span><span id="line-246"></span><span class="hs-comment">-- and there may be several imported 'f's too, which must not confuse us.</span><span>
</span><span id="line-247"></span><span class="hs-comment">-- For example, this is OK:</span><span>
</span><span id="line-248"></span><span class="hs-comment">--      import Foo( f )</span><span>
</span><span id="line-249"></span><span class="hs-comment">--      infix 9 f       -- The 'f' here does not need to be qualified</span><span>
</span><span id="line-250"></span><span class="hs-comment">--      f x = x         -- Nor here, of course</span><span>
</span><span id="line-251"></span><span class="hs-comment">-- So we have to filter out the non-local ones.</span><span>
</span><span id="line-252"></span><span class="hs-comment">--</span><span>
</span><span id="line-253"></span><span class="hs-comment">-- A separate function (importsFromLocalDecls) reports duplicate top level</span><span>
</span><span id="line-254"></span><span class="hs-comment">-- decls, so here it's safe just to choose an arbitrary one.</span><span>
</span><span id="line-255"></span><span id="lookupTopBndrRn"><span class="annot"><span class="annottext">lookupTopBndrRn :: RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupTopBndrRn"><span class="hs-identifier hs-var hs-var">lookupTopBndrRn</span></a></span></span><span> </span><span id="local-6989586621681107857"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107857"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-256"></span><span>  </span><span class="annot"><span class="annottext">RdrName -&gt; (Name -&gt; Name) -&gt; RnM Name -&gt; RnM Name
forall r. RdrName -&gt; (Name -&gt; r) -&gt; RnM r -&gt; RnM r
</span><a href="GHC.Rename.Env.html#lookupExactOrOrig"><span class="hs-identifier hs-var">lookupExactOrOrig</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107857"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">(RnM Name -&gt; RnM Name) -&gt; RnM Name -&gt; RnM Name
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-257"></span><span>    </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span>  </span><span class="hs-comment">-- Check for operators in type or class declarations</span><span>
</span><span id="line-258"></span><span>           </span><span class="hs-comment">-- See Note [Type and class operator definitions]</span><span>
</span><span id="line-259"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107854"><span class="annot"><span class="annottext">occ :: OccName
</span><a href="#local-6989586621681107854"><span class="hs-identifier hs-var hs-var">occ</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#rdrNameOcc"><span class="hs-identifier hs-var">rdrNameOcc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107857"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-260"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; Bool
</span><a href="GHC.Types.Name.Occurrence.html#isTcOcc"><span class="hs-identifier hs-var">isTcOcc</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107854"><span class="hs-identifier hs-var">occ</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; Bool
</span><a href="GHC.Types.Name.Occurrence.html#isSymOcc"><span class="hs-identifier hs-var">isSymOcc</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107854"><span class="hs-identifier hs-var">occ</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-261"></span><span>               </span><span class="hs-special">(</span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107850"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107850"><span class="hs-identifier hs-var">op_ok</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#TypeOperators"><span class="hs-identifier hs-var">LangExt.TypeOperators</span></a></span><span>
</span><span id="line-262"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107850"><span class="hs-identifier hs-var">op_ok</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
</span><a href="GHC.Rename.Env.html#opDeclErr"><span class="hs-identifier hs-var">opDeclErr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107857"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-263"></span><span>
</span><span id="line-264"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681107845"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107845"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn GlobalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getGlobalRdrEnv"><span class="hs-identifier hs-var">getGlobalRdrEnv</span></a></span><span>
</span><span id="line-265"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Bool) -&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#isLocalGRE"><span class="hs-identifier hs-var">isLocalGRE</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; GlobalRdrEnv -&gt; [GlobalRdrElt]
</span><a href="GHC.Types.Name.Reader.html#lookupGRE_RdrName"><span class="hs-identifier hs-var">lookupGRE_RdrName</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107857"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107845"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-266"></span><span>            </span><span class="hs-special">[</span><span id="local-6989586621681107841"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107841"><span class="hs-identifier hs-var">gre</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107841"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-267"></span><span>            </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-comment">-- Ambiguous (can't happen) or unbound</span><span>
</span><span id="line-268"></span><span>                        </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupTopBndrRN fail&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107857"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-269"></span><span>                        </span><span class="annot"><span class="annottext">WhereLooking -&gt; RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Unbound.html#unboundName"><span class="hs-identifier hs-var">unboundName</span></a></span><span> </span><span class="annot"><span class="annottext">WhereLooking
</span><a href="GHC.Rename.Unbound.html#WL_LocalTop"><span class="hs-identifier hs-var">WL_LocalTop</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107857"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-270"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-271"></span><span>
</span><span id="line-272"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocatedTopBndrRn"><span class="hs-identifier hs-type">lookupLocatedTopBndrRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-273"></span><span id="lookupLocatedTopBndrRn"><span class="annot"><span class="annottext">lookupLocatedTopBndrRn :: Located RdrName -&gt; RnM (Located Name)
</span><a href="GHC.Rename.Env.html#lookupLocatedTopBndrRn"><span class="hs-identifier hs-var hs-var">lookupLocatedTopBndrRn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(RdrName -&gt; RnM Name) -&gt; Located RdrName -&gt; RnM (Located Name)
forall a b. (a -&gt; TcM b) -&gt; Located a -&gt; TcM (Located b)
</span><a href="GHC.Tc.Utils.Monad.html#wrapLocM"><span class="hs-identifier hs-var">wrapLocM</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupTopBndrRn"><span class="hs-identifier hs-var">lookupTopBndrRn</span></a></span><span>
</span><span id="line-274"></span><span>
</span><span id="line-275"></span><span class="hs-comment">-- | Lookup an @Exact@ @RdrName@. See Note [Looking up Exact RdrNames].</span><span>
</span><span id="line-276"></span><span class="hs-comment">-- This never adds an error, but it may return one, see</span><span>
</span><span id="line-277"></span><span class="hs-comment">-- Note [Errors in lookup functions]</span><span>
</span><span id="line-278"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupExactOcc_either"><span class="hs-identifier hs-type">lookupExactOcc_either</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-279"></span><span id="lookupExactOcc_either"><span class="annot"><span class="annottext">lookupExactOcc_either :: Name -&gt; RnM (Either MsgDoc Name)
</span><a href="GHC.Rename.Env.html#lookupExactOcc_either"><span class="hs-identifier hs-var hs-var">lookupExactOcc_either</span></a></span></span><span> </span><span id="local-6989586621681107835"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-280"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107834"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681107834"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Maybe TyThing
</span><a href="GHC.Types.Name.html#wiredInNameTyThing_maybe"><span class="hs-identifier hs-var">wiredInNameTyThing_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-281"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107832"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681107832"><span class="hs-identifier hs-var">tycon</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681107834"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-282"></span><span>                    </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ATyCon"><span class="hs-identifier hs-type">ATyCon</span></a></span><span> </span><span id="local-6989586621681107830"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681107830"><span class="hs-identifier hs-var">tc</span></a></span></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe TyCon
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681107830"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-283"></span><span>                    </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AConLike"><span class="hs-identifier hs-type">AConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-type">RealDataCon</span></a></span><span> </span><span id="local-6989586621681107827"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681107827"><span class="hs-identifier hs-var">dc</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe TyCon
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; TyCon
</span><a href="GHC.Core.DataCon.html#dataConTyCon"><span class="hs-identifier hs-var">dataConTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681107827"><span class="hs-identifier hs-var">dc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-284"></span><span>                    </span><span class="annot"><span class="annottext">TyThing
</span><span class="hs-identifier">_</span></span><span>                         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe TyCon
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-285"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107825"><span class="annot"><span class="annottext">TupleSort
</span><a href="#local-6989586621681107825"><span class="hs-identifier hs-var">tupleSort</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe TupleSort
</span><a href="GHC.Core.TyCon.html#tyConTuple_maybe"><span class="hs-identifier hs-var">tyConTuple_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681107832"><span class="hs-identifier hs-var">tycon</span></a></span><span>
</span><span id="line-286"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107819"><span class="annot"><span class="annottext">tupArity :: Arity
</span><a href="#local-6989586621681107819"><span class="hs-identifier hs-var hs-var">tupArity</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TupleSort
</span><a href="#local-6989586621681107825"><span class="hs-identifier hs-var">tupleSort</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-287"></span><span>               </span><span class="hs-comment">-- Unboxed tuples have twice as many arguments because of the</span><span>
</span><span id="line-288"></span><span>               </span><span class="hs-comment">-- 'RuntimeRep's (#17837)</span><span>
</span><span id="line-289"></span><span>               </span><span class="annot"><span class="annottext">TupleSort
</span><a href="GHC.Types.Basic.html#UnboxedTuple"><span class="hs-identifier hs-var">UnboxedTuple</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Arity
</span><a href="GHC.Core.TyCon.html#tyConArity"><span class="hs-identifier hs-var hs-var">tyConArity</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681107832"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">Arity -&gt; Arity -&gt; Arity
forall a. Integral a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#div"><span class="hs-operator hs-var">`div`</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">2</span></span><span>
</span><span id="line-290"></span><span>               </span><span class="annot"><span class="annottext">TupleSort
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Arity
</span><a href="GHC.Core.TyCon.html#tyConArity"><span class="hs-identifier hs-var hs-var">tyConArity</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681107832"><span class="hs-identifier hs-var">tycon</span></a></span><span>
</span><span id="line-291"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Arity -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Utils.html#checkTupSize"><span class="hs-identifier hs-var">checkTupSize</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621681107819"><span class="hs-identifier hs-var">tupArity</span></a></span><span>
</span><span id="line-292"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either MsgDoc Name
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-293"></span><span>
</span><span id="line-294"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isExternalName"><span class="hs-identifier hs-var">isExternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-295"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either MsgDoc Name
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-296"></span><span>
</span><span id="line-297"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-298"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107814"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107814"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn GlobalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getGlobalRdrEnv"><span class="hs-identifier hs-var">getGlobalRdrEnv</span></a></span><span>
</span><span id="line-299"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-comment">-- See Note [Splicing Exact names]</span><span>
</span><span id="line-300"></span><span>             </span><span id="local-6989586621681107813"><span class="annot"><span class="annottext">main_occ :: OccName
</span><a href="#local-6989586621681107813"><span class="hs-identifier hs-var hs-var">main_occ</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-301"></span><span>             </span><span id="local-6989586621681107811"><span class="annot"><span class="annottext">demoted_occs :: [OccName]
</span><a href="#local-6989586621681107811"><span class="hs-identifier hs-var hs-var">demoted_occs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; Maybe OccName
</span><a href="GHC.Types.Name.Occurrence.html#demoteOccName"><span class="hs-identifier hs-var">demoteOccName</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107813"><span class="hs-identifier hs-var">main_occ</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-302"></span><span>                              </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107809"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107809"><span class="hs-identifier hs-var">occ</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107809"><span class="hs-identifier hs-var">occ</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-303"></span><span>                              </span><span class="annot"><span class="annottext">Maybe OccName
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-304"></span><span>             </span><span id="local-6989586621681107807"><span class="annot"><span class="annottext">gres :: [GlobalRdrElt]
</span><a href="#local-6989586621681107807"><span class="hs-identifier hs-var hs-var">gres</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107806"><span class="hs-identifier hs-var">gre</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681107805"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107805"><span class="hs-identifier hs-var">occ</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107813"><span class="hs-identifier hs-var">main_occ</span></a></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; [OccName] -&gt; [OccName]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[OccName]
</span><a href="#local-6989586621681107811"><span class="hs-identifier hs-var">demoted_occs</span></a></span><span>
</span><span id="line-305"></span><span>                          </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681107806"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107806"><span class="hs-identifier hs-var">gre</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv -&gt; OccName -&gt; [GlobalRdrElt]
</span><a href="GHC.Types.Name.Reader.html#lookupGlobalRdrEnv"><span class="hs-identifier hs-var">lookupGlobalRdrEnv</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107814"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107805"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-306"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107806"><span class="hs-identifier hs-var">gre</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-307"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107807"><span class="hs-identifier hs-var">gres</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-308"></span><span>           </span><span class="hs-special">[</span><span id="local-6989586621681107803"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107803"><span class="hs-identifier hs-var">gre</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either MsgDoc Name
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107803"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-309"></span><span>
</span><span id="line-310"></span><span>           </span><span class="hs-special">[</span><span class="hs-special">]</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-comment">-- See Note [Splicing Exact names]</span><span>
</span><span id="line-311"></span><span>                    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107802"><span class="annot"><span class="annottext">LocalRdrEnv
</span><a href="#local-6989586621681107802"><span class="hs-identifier hs-var">lcl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RnM LocalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getLocalRdrEnv"><span class="hs-identifier hs-var">getLocalRdrEnv</span></a></span><span>
</span><span id="line-312"></span><span>                       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; LocalRdrEnv -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#inLocalRdrEnvScope"><span class="hs-operator hs-var">`inLocalRdrEnvScope`</span></a></span><span> </span><span class="annot"><span class="annottext">LocalRdrEnv
</span><a href="#local-6989586621681107802"><span class="hs-identifier hs-var">lcl_env</span></a></span><span>
</span><span id="line-313"></span><span>                         </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either MsgDoc Name
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-314"></span><span>                         </span><span class="hs-keyword">else</span><span>
</span><span id="line-315"></span><span>                         </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107799"><span class="annot"><span class="annottext">TcRef NameSet
</span><a href="#local-6989586621681107799"><span class="hs-identifier hs-var">th_topnames_var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TcGblEnv -&gt; TcRef NameSet)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TcRef NameSet)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcRef NameSet
</span><a href="GHC.Tc.Types.html#tcg_th_topnames"><span class="hs-identifier hs-var hs-var">tcg_th_topnames</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-316"></span><span>                            </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681107796"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107796"><span class="hs-identifier hs-var">th_topnames</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRef NameSet -&gt; TcRnIf TcGblEnv TcLclEnv NameSet
forall a gbl lcl. TcRef a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#readTcRef"><span class="hs-identifier hs-var">readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">TcRef NameSet
</span><a href="#local-6989586621681107799"><span class="hs-identifier hs-var">th_topnames_var</span></a></span><span>
</span><span id="line-317"></span><span>                            </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; NameSet -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#elemNameSet"><span class="hs-operator hs-var">`elemNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107796"><span class="hs-identifier hs-var">th_topnames</span></a></span><span>
</span><span id="line-318"></span><span>                              </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either MsgDoc Name
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-319"></span><span>                              </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; Either MsgDoc Name
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
</span><a href="GHC.Rename.Unbound.html#exactNameErr"><span class="hs-identifier hs-var">exactNameErr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107835"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-320"></span><span>                            </span><span class="hs-special">}</span><span>
</span><span id="line-321"></span><span>                       </span><span class="hs-special">}</span><span>
</span><span id="line-322"></span><span>           </span><span id="local-6989586621681107792"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107792"><span class="hs-identifier hs-var">gres</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; Either MsgDoc Name
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; MsgDoc
</span><a href="GHC.Rename.Env.html#sameNameErr"><span class="hs-identifier hs-var">sameNameErr</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107792"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- Ugh!  See Note [Template Haskell ambiguity]</span><span>
</span><span id="line-323"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-324"></span><span>
</span><span id="line-325"></span><span class="annot"><a href="GHC.Rename.Env.html#sameNameErr"><span class="hs-identifier hs-type">sameNameErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span>
</span><span id="line-326"></span><span id="sameNameErr"><span class="annot"><span class="annottext">sameNameErr :: [GlobalRdrElt] -&gt; MsgDoc
</span><a href="GHC.Rename.Env.html#sameNameErr"><span class="hs-identifier hs-var hs-var">sameNameErr</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;addSameNameErr: empty list&quot;</span></span><span>
</span><span id="line-327"></span><span class="annot"><a href="GHC.Rename.Env.html#sameNameErr"><span class="hs-identifier hs-var">sameNameErr</span></a></span><span> </span><span id="local-6989586621681107789"><span class="annot"><span class="annottext">gres :: [GlobalRdrElt]
</span><a href="#local-6989586621681107789"><span class="hs-identifier hs-var">gres</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-328"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Arity -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Same exact name in multiple name-spaces:&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span>       </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Name -&gt; MsgDoc) -&gt; [Name] -&gt; [MsgDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
</span><a href="#local-6989586621681107785"><span class="hs-identifier hs-var">pp_one</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107784"><span class="hs-identifier hs-var">sorted_names</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107783"><span class="hs-identifier hs-var">th_hint</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-330"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-331"></span><span>    </span><span id="local-6989586621681107784"><span class="annot"><span class="annottext">sorted_names :: [Name]
</span><a href="#local-6989586621681107784"><span class="hs-identifier hs-var hs-var">sorted_names</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Name -&gt; Ordering) -&gt; [Name] -&gt; [Name]
forall a. (a -&gt; a -&gt; Ordering) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sortBy"><span class="hs-identifier hs-var">sortBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; SrcSpan -&gt; Ordering
</span><a href="GHC.Types.SrcLoc.html#leftmost_smallest"><span class="hs-identifier hs-var">SrcLoc.leftmost_smallest</span></a></span><span> </span><span class="annot"><span class="annottext">(SrcSpan -&gt; SrcSpan -&gt; Ordering)
-&gt; (Name -&gt; SrcSpan) -&gt; Name -&gt; Name -&gt; Ordering
forall b c a. (b -&gt; b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; a -&gt; c
</span><a href="../../base/src/Data.Function.html#on"><span class="hs-operator hs-var">`on`</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#nameSrcSpan"><span class="hs-identifier hs-var">nameSrcSpan</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Name) -&gt; [GlobalRdrElt] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107789"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-332"></span><span>    </span><span id="local-6989586621681107785"><span class="annot"><span class="annottext">pp_one :: Name -&gt; MsgDoc
</span><a href="#local-6989586621681107785"><span class="hs-identifier hs-var hs-var">pp_one</span></a></span></span><span> </span><span id="local-6989586621681107774"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107774"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-333"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Arity -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NameSpace -&gt; MsgDoc
</span><a href="GHC.Types.Name.Occurrence.html#pprNameSpace"><span class="hs-identifier hs-var">pprNameSpace</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; NameSpace
</span><a href="GHC.Types.Name.Occurrence.html#occNameSpace"><span class="hs-identifier hs-var hs-var">occNameSpace</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107774"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-334"></span><span>              </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107774"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-335"></span><span>           </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;declared at:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SrcLoc -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SrcLoc
</span><a href="GHC.Types.Name.html#nameSrcLoc"><span class="hs-identifier hs-var">nameSrcLoc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107774"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-336"></span><span>
</span><span id="line-337"></span><span>    </span><span id="local-6989586621681107783"><span class="annot"><span class="annottext">th_hint :: MsgDoc
</span><a href="#local-6989586621681107783"><span class="hs-identifier hs-var hs-var">th_hint</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Probable cause: you bound a unique Template Haskell name (NameU),&quot;</span></span><span>
</span><span id="line-338"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;perhaps via newName, in different name-spaces.&quot;</span></span><span>
</span><span id="line-339"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;If that's it, then -ddump-splices might be useful&quot;</span></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-340"></span><span>
</span><span id="line-341"></span><span>
</span><span id="line-342"></span><span class="hs-comment">-----------------------------------------------</span><span>
</span><span id="line-343"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupInstDeclBndr"><span class="hs-identifier hs-type">lookupInstDeclBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-344"></span><span class="hs-comment">-- This is called on the method name on the left-hand side of an</span><span>
</span><span id="line-345"></span><span class="hs-comment">-- instance declaration binding. eg.  instance Functor T where</span><span>
</span><span id="line-346"></span><span class="hs-comment">--                                       fmap = ...</span><span>
</span><span id="line-347"></span><span class="hs-comment">--                                       ^^^^ called on this</span><span>
</span><span id="line-348"></span><span class="hs-comment">-- Regardless of how many unqualified fmaps are in scope, we want</span><span>
</span><span id="line-349"></span><span class="hs-comment">-- the one that comes from the Functor class.</span><span>
</span><span id="line-350"></span><span class="hs-comment">--</span><span>
</span><span id="line-351"></span><span class="hs-comment">-- Furthermore, note that we take no account of whether the</span><span>
</span><span id="line-352"></span><span class="hs-comment">-- name is only in scope qualified.  I.e. even if method op is</span><span>
</span><span id="line-353"></span><span class="hs-comment">-- in scope as M.op, we still allow plain 'op' on the LHS of</span><span>
</span><span id="line-354"></span><span class="hs-comment">-- an instance decl</span><span>
</span><span id="line-355"></span><span class="hs-comment">--</span><span>
</span><span id="line-356"></span><span class="hs-comment">-- The &quot;what&quot; parameter says &quot;method&quot; or &quot;associated type&quot;,</span><span>
</span><span id="line-357"></span><span class="hs-comment">-- depending on what we are looking up</span><span>
</span><span id="line-358"></span><span id="lookupInstDeclBndr"><span class="annot"><span class="annottext">lookupInstDeclBndr :: Name -&gt; MsgDoc -&gt; RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupInstDeclBndr"><span class="hs-identifier hs-var hs-var">lookupInstDeclBndr</span></a></span></span><span> </span><span id="local-6989586621681107764"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107764"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681107763"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107763"><span class="hs-identifier hs-var">what</span></a></span></span><span> </span><span id="local-6989586621681107762"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107762"><span class="hs-identifier hs-var">rdr</span></a></span></span><span>
</span><span id="line-359"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#isQual"><span class="hs-identifier hs-var">isQual</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107762"><span class="hs-identifier hs-var">rdr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-360"></span><span>              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
</span><a href="GHC.Rename.Utils.html#badQualBndrErr"><span class="hs-identifier hs-var">badQualBndrErr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107762"><span class="hs-identifier hs-var">rdr</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-361"></span><span>                </span><span class="hs-comment">-- In an instance decl you aren't allowed</span><span>
</span><span id="line-362"></span><span>                </span><span class="hs-comment">-- to use a qualified name for the method</span><span>
</span><span id="line-363"></span><span>                </span><span class="hs-comment">-- (Although it'd make perfect sense.)</span><span>
</span><span id="line-364"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681107761"><span class="annot"><span class="annottext">Either MsgDoc Name
</span><a href="#local-6989586621681107761"><span class="hs-identifier hs-var">mb_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Name -&gt; MsgDoc -&gt; RdrName -&gt; RnM (Either MsgDoc Name)
</span><a href="GHC.Rename.Env.html#lookupSubBndrOcc"><span class="hs-identifier hs-var">lookupSubBndrOcc</span></a></span><span>
</span><span id="line-365"></span><span>                          </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-comment">-- False =&gt; we don't give deprecated</span><span>
</span><span id="line-366"></span><span>                                </span><span class="hs-comment">-- warnings when a deprecated class</span><span>
</span><span id="line-367"></span><span>                                </span><span class="hs-comment">-- method is defined. We only warn</span><span>
</span><span id="line-368"></span><span>                                </span><span class="hs-comment">-- when it's used</span><span>
</span><span id="line-369"></span><span>                          </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107764"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107759"><span class="hs-identifier hs-var">doc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107762"><span class="hs-identifier hs-var">rdr</span></a></span><span>
</span><span id="line-370"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name
</span><a href="#local-6989586621681107761"><span class="hs-identifier hs-var">mb_name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-371"></span><span>           </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681107758"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107758"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107758"><span class="hs-identifier hs-var">err</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; Name
</span><a href="GHC.Rename.Unbound.html#mkUnboundNameRdr"><span class="hs-identifier hs-var">mkUnboundNameRdr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107762"><span class="hs-identifier hs-var">rdr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-372"></span><span>           </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621681107756"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107756"><span class="hs-identifier hs-var">nm</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107756"><span class="hs-identifier hs-var">nm</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-373"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-374"></span><span>    </span><span id="local-6989586621681107759"><span class="annot"><span class="annottext">doc :: MsgDoc
</span><a href="#local-6989586621681107759"><span class="hs-identifier hs-var hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107763"><span class="hs-identifier hs-var">what</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;of class&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107764"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-375"></span><span>
</span><span id="line-376"></span><span class="hs-comment">-----------------------------------------------</span><span>
</span><span id="line-377"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupFamInstName"><span class="hs-identifier hs-type">lookupFamInstName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span>
</span><span id="line-378"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-379"></span><span class="hs-comment">-- Used for TyData and TySynonym family instances only,</span><span>
</span><span id="line-380"></span><span class="hs-comment">-- See Note [Family instance binders]</span><span>
</span><span id="line-381"></span><span id="lookupFamInstName"><span class="annot"><span class="annottext">lookupFamInstName :: Maybe Name -&gt; Located RdrName -&gt; RnM (Located Name)
</span><a href="GHC.Rename.Env.html#lookupFamInstName"><span class="hs-identifier hs-var hs-var">lookupFamInstName</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107754"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107754"><span class="hs-identifier hs-var">cls</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681107753"><span class="annot"><span class="annottext">Located RdrName
</span><a href="#local-6989586621681107753"><span class="hs-identifier hs-var">tc_rdr</span></a></span></span><span>  </span><span class="hs-comment">-- Associated type; c.f GHC.Rename.Bind.rnMethodBind</span><span>
</span><span id="line-382"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(RdrName -&gt; RnM Name) -&gt; Located RdrName -&gt; RnM (Located Name)
forall a b. (a -&gt; TcM b) -&gt; Located a -&gt; TcM (Located b)
</span><a href="GHC.Tc.Utils.Monad.html#wrapLocM"><span class="hs-identifier hs-var">wrapLocM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc -&gt; RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupInstDeclBndr"><span class="hs-identifier hs-var">lookupInstDeclBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107754"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;associated type&quot;</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Located RdrName
</span><a href="#local-6989586621681107753"><span class="hs-identifier hs-var">tc_rdr</span></a></span><span>
</span><span id="line-383"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupFamInstName"><span class="hs-identifier hs-var">lookupFamInstName</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span id="local-6989586621681107752"><span class="annot"><span class="annottext">Located RdrName
</span><a href="#local-6989586621681107752"><span class="hs-identifier hs-var">tc_rdr</span></a></span></span><span>     </span><span class="hs-comment">-- Family instance; tc_rdr is an *occurrence*</span><span>
</span><span id="line-384"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Located RdrName -&gt; RnM (Located Name)
</span><a href="GHC.Rename.Env.html#lookupLocatedOccRn"><span class="hs-identifier hs-var">lookupLocatedOccRn</span></a></span><span> </span><span class="annot"><span class="annottext">Located RdrName
</span><a href="#local-6989586621681107752"><span class="hs-identifier hs-var">tc_rdr</span></a></span><span>
</span><span id="line-385"></span><span>
</span><span id="line-386"></span><span class="hs-comment">-----------------------------------------------</span><span>
</span><span id="line-387"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupConstructorFields"><span class="hs-identifier hs-type">lookupConstructorFields</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.FieldLabel.html#FieldLabel"><span class="hs-identifier hs-type">FieldLabel</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-388"></span><span class="hs-comment">-- Look up the fields of a given constructor</span><span>
</span><span id="line-389"></span><span class="hs-comment">--   *  For constructors from this module, use the record field env,</span><span>
</span><span id="line-390"></span><span class="hs-comment">--      which is itself gathered from the (as yet un-typechecked)</span><span>
</span><span id="line-391"></span><span class="hs-comment">--      data type decls</span><span>
</span><span id="line-392"></span><span class="hs-comment">--</span><span>
</span><span id="line-393"></span><span class="hs-comment">--    * For constructors from imported modules, use the *type* environment</span><span>
</span><span id="line-394"></span><span class="hs-comment">--      since imported modules are already compiled, the info is conveniently</span><span>
</span><span id="line-395"></span><span class="hs-comment">--      right there</span><span>
</span><span id="line-396"></span><span>
</span><span id="line-397"></span><span id="lookupConstructorFields"><span class="annot"><span class="annottext">lookupConstructorFields :: Name -&gt; RnM [FieldLabel]
</span><a href="GHC.Rename.Env.html#lookupConstructorFields"><span class="hs-identifier hs-var hs-var">lookupConstructorFields</span></a></span></span><span> </span><span id="local-6989586621681107751"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107751"><span class="hs-identifier hs-var">con_name</span></a></span></span><span>
</span><span id="line-398"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107750"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107750"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-399"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Module -&gt; Name -&gt; Bool
</span><a href="GHC.Types.Name.html#nameIsLocalOrFrom"><span class="hs-identifier hs-var">nameIsLocalOrFrom</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107750"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107751"><span class="hs-identifier hs-var">con_name</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-400"></span><span>          </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107748"><span class="annot"><span class="annottext">RecFieldEnv
</span><a href="#local-6989586621681107748"><span class="hs-identifier hs-var">field_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn RecFieldEnv
</span><a href="GHC.Tc.Utils.Monad.html#getRecFieldEnv"><span class="hs-identifier hs-var">getRecFieldEnv</span></a></span><span>
</span><span id="line-401"></span><span>             </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupCF&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107751"><span class="hs-identifier hs-var">con_name</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe [FieldLabel] -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RecFieldEnv -&gt; Name -&gt; Maybe [FieldLabel]
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">RecFieldEnv
</span><a href="#local-6989586621681107748"><span class="hs-identifier hs-var">field_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107751"><span class="hs-identifier hs-var">con_name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">RecFieldEnv -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RecFieldEnv
</span><a href="#local-6989586621681107748"><span class="hs-identifier hs-var">field_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-402"></span><span>             </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[FieldLabel] -&gt; RnM [FieldLabel]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RecFieldEnv -&gt; Name -&gt; Maybe [FieldLabel]
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">RecFieldEnv
</span><a href="#local-6989586621681107748"><span class="hs-identifier hs-var">field_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107751"><span class="hs-identifier hs-var">con_name</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe [FieldLabel] -&gt; [FieldLabel] -&gt; [FieldLabel]
forall a. Maybe a -&gt; a -&gt; a
</span><a href="GHC.Data.Maybe.html#orElse"><span class="hs-operator hs-var">`orElse`</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-403"></span><span>          </span><span class="hs-keyword">else</span><span>
</span><span id="line-404"></span><span>          </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107743"><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681107743"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM ConLike
</span><a href="GHC.Tc.Utils.Env.html#tcLookupConLike"><span class="hs-identifier hs-var">tcLookupConLike</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107751"><span class="hs-identifier hs-var">con_name</span></a></span><span>
</span><span id="line-405"></span><span>             </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupCF 2&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681107743"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-406"></span><span>             </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[FieldLabel] -&gt; RnM [FieldLabel]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConLike -&gt; [FieldLabel]
</span><a href="GHC.Core.ConLike.html#conLikeFieldLabels"><span class="hs-identifier hs-var">conLikeFieldLabels</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681107743"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-407"></span><span>
</span><span id="line-408"></span><span>
</span><span id="line-409"></span><span class="hs-comment">-- In CPS style as `RnM r` is monadic</span><span>
</span><span id="line-410"></span><span class="hs-comment">-- Reports an error if the name is an Exact or Orig and it can't find the name</span><span>
</span><span id="line-411"></span><span class="hs-comment">-- Otherwise if it is not an Exact or Orig, returns k</span><span>
</span><span id="line-412"></span><span id="local-6989586621681108404"><span class="annot"><a href="GHC.Rename.Env.html#lookupExactOrOrig"><span class="hs-identifier hs-type">lookupExactOrOrig</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681108404"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681108404"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681108404"><span class="hs-identifier hs-type">r</span></a></span></span><span>
</span><span id="line-413"></span><span id="lookupExactOrOrig"><span class="annot"><span class="annottext">lookupExactOrOrig :: forall r. RdrName -&gt; (Name -&gt; r) -&gt; RnM r -&gt; RnM r
</span><a href="GHC.Rename.Env.html#lookupExactOrOrig"><span class="hs-identifier hs-var hs-var">lookupExactOrOrig</span></a></span></span><span> </span><span id="local-6989586621681107736"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107736"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span> </span><span id="local-6989586621681107735"><span class="annot"><span class="annottext">Name -&gt; r
</span><a href="#local-6989586621681107735"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span id="local-6989586621681107734"><span class="annot"><span class="annottext">RnM r
</span><a href="#local-6989586621681107734"><span class="hs-identifier hs-var">k</span></a></span></span><span>
</span><span id="line-414"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107733"><span class="annot"><span class="annottext">ExactOrOrigResult
</span><a href="#local-6989586621681107733"><span class="hs-identifier hs-var">men</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM ExactOrOrigResult
</span><a href="GHC.Rename.Env.html#lookupExactOrOrig_base"><span class="hs-identifier hs-var">lookupExactOrOrig_base</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107736"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-415"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ExactOrOrigResult
</span><a href="#local-6989586621681107733"><span class="hs-identifier hs-var">men</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-416"></span><span>          </span><span class="annot"><a href="GHC.Rename.Env.html#FoundExactOrOrig"><span class="hs-identifier hs-type">FoundExactOrOrig</span></a></span><span> </span><span id="local-6989586621681107730"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107730"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">r -&gt; RnM r
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; r
</span><a href="#local-6989586621681107735"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107730"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-417"></span><span>          </span><span class="annot"><a href="GHC.Rename.Env.html#ExactOrOrigError"><span class="hs-identifier hs-type">ExactOrOrigError</span></a></span><span> </span><span id="local-6989586621681107728"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107728"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-418"></span><span>            </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107728"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-419"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">r -&gt; RnM r
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; r
</span><a href="#local-6989586621681107735"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; Name
</span><a href="GHC.Rename.Unbound.html#mkUnboundNameRdr"><span class="hs-identifier hs-var">mkUnboundNameRdr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107736"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-420"></span><span>          </span><span class="annot"><span class="annottext">ExactOrOrigResult
</span><a href="GHC.Rename.Env.html#NotExactOrOrig"><span class="hs-identifier hs-var">NotExactOrOrig</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RnM r
</span><a href="#local-6989586621681107734"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-421"></span><span>
</span><span id="line-422"></span><span class="hs-comment">-- Variant of 'lookupExactOrOrig' that does not report an error</span><span>
</span><span id="line-423"></span><span class="hs-comment">-- See Note [Errors in lookup functions]</span><span>
</span><span id="line-424"></span><span class="hs-comment">-- Calls k if the name is neither an Exact nor Orig</span><span>
</span><span id="line-425"></span><span id="local-6989586621681108354"><span class="annot"><a href="GHC.Rename.Env.html#lookupExactOrOrig_maybe"><span class="hs-identifier hs-type">lookupExactOrOrig_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681108354"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681108354"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681108354"><span class="hs-identifier hs-type">r</span></a></span></span><span>
</span><span id="line-426"></span><span id="lookupExactOrOrig_maybe"><span class="annot"><span class="annottext">lookupExactOrOrig_maybe :: forall r. RdrName -&gt; (Maybe Name -&gt; r) -&gt; RnM r -&gt; RnM r
</span><a href="GHC.Rename.Env.html#lookupExactOrOrig_maybe"><span class="hs-identifier hs-var hs-var">lookupExactOrOrig_maybe</span></a></span></span><span> </span><span id="local-6989586621681107722"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107722"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span> </span><span id="local-6989586621681107721"><span class="annot"><span class="annottext">Maybe Name -&gt; r
</span><a href="#local-6989586621681107721"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span id="local-6989586621681107720"><span class="annot"><span class="annottext">RnM r
</span><a href="#local-6989586621681107720"><span class="hs-identifier hs-var">k</span></a></span></span><span>
</span><span id="line-427"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107719"><span class="annot"><span class="annottext">ExactOrOrigResult
</span><a href="#local-6989586621681107719"><span class="hs-identifier hs-var">men</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM ExactOrOrigResult
</span><a href="GHC.Rename.Env.html#lookupExactOrOrig_base"><span class="hs-identifier hs-var">lookupExactOrOrig_base</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107722"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-428"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ExactOrOrigResult
</span><a href="#local-6989586621681107719"><span class="hs-identifier hs-var">men</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-429"></span><span>           </span><span class="annot"><a href="GHC.Rename.Env.html#FoundExactOrOrig"><span class="hs-identifier hs-type">FoundExactOrOrig</span></a></span><span> </span><span id="local-6989586621681107718"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107718"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">r -&gt; RnM r
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Name -&gt; r
</span><a href="#local-6989586621681107721"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Maybe Name
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107718"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-430"></span><span>           </span><span class="annot"><a href="GHC.Rename.Env.html#ExactOrOrigError"><span class="hs-identifier hs-type">ExactOrOrigError</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">r -&gt; RnM r
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Name -&gt; r
</span><a href="#local-6989586621681107721"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Name
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-431"></span><span>           </span><span class="annot"><span class="annottext">ExactOrOrigResult
</span><a href="GHC.Rename.Env.html#NotExactOrOrig"><span class="hs-identifier hs-var">NotExactOrOrig</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RnM r
</span><a href="#local-6989586621681107720"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-432"></span><span>
</span><span id="line-433"></span><span class="hs-keyword">data</span><span> </span><span id="ExactOrOrigResult"><span class="annot"><a href="GHC.Rename.Env.html#ExactOrOrigResult"><span class="hs-identifier hs-var">ExactOrOrigResult</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="FoundExactOrOrig"><span class="annot"><a href="GHC.Rename.Env.html#FoundExactOrOrig"><span class="hs-identifier hs-var">FoundExactOrOrig</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-comment">-- ^ Found an Exact Or Orig Name</span><span>
</span><span id="line-434"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span id="ExactOrOrigError"><span class="annot"><a href="GHC.Rename.Env.html#ExactOrOrigError"><span class="hs-identifier hs-var">ExactOrOrigError</span></a></span></span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span> </span><span class="hs-comment">-- ^ The RdrName was an Exact</span><span>
</span><span id="line-435"></span><span>                                                 </span><span class="hs-comment">-- or Orig, but there was an</span><span>
</span><span id="line-436"></span><span>                                                 </span><span class="hs-comment">-- error looking up the Name</span><span>
</span><span id="line-437"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span id="NotExactOrOrig"><span class="annot"><a href="GHC.Rename.Env.html#NotExactOrOrig"><span class="hs-identifier hs-var">NotExactOrOrig</span></a></span></span><span> </span><span class="hs-comment">-- ^ The RdrName is neither an Exact nor</span><span>
</span><span id="line-438"></span><span>                                        </span><span class="hs-comment">-- Orig</span><span>
</span><span id="line-439"></span><span>
</span><span id="line-440"></span><span class="hs-comment">-- Does the actual looking up an Exact or Orig name, see 'ExactOrOrigResult'</span><span>
</span><span id="line-441"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupExactOrOrig_base"><span class="hs-identifier hs-type">lookupExactOrOrig_base</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#ExactOrOrigResult"><span class="hs-identifier hs-type">ExactOrOrigResult</span></a></span><span>
</span><span id="line-442"></span><span id="lookupExactOrOrig_base"><span class="annot"><span class="annottext">lookupExactOrOrig_base :: RdrName -&gt; RnM ExactOrOrigResult
</span><a href="GHC.Rename.Env.html#lookupExactOrOrig_base"><span class="hs-identifier hs-var hs-var">lookupExactOrOrig_base</span></a></span></span><span> </span><span id="local-6989586621681107717"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107717"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-443"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107716"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107716"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; Maybe Name
</span><a href="GHC.Types.Name.Reader.html#isExact_maybe"><span class="hs-identifier hs-var">isExact_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107717"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>   </span><span class="hs-comment">-- This happens in derived code</span><span>
</span><span id="line-444"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; ExactOrOrigResult
</span><a href="#local-6989586621681107715"><span class="hs-identifier hs-var">cvtEither</span></a></span><span> </span><span class="annot"><span class="annottext">(Either MsgDoc Name -&gt; ExactOrOrigResult)
-&gt; RnM (Either MsgDoc Name) -&gt; RnM ExactOrOrigResult
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM (Either MsgDoc Name)
</span><a href="GHC.Rename.Env.html#lookupExactOcc_either"><span class="hs-identifier hs-var">lookupExactOcc_either</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107716"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-445"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681107713"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107713"><span class="hs-identifier hs-var">rdr_mod</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681107712"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107712"><span class="hs-identifier hs-var">rdr_occ</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; Maybe (Module, OccName)
</span><a href="GHC.Types.Name.Reader.html#isOrig_maybe"><span class="hs-identifier hs-var">isOrig_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107717"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-446"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; ExactOrOrigResult
</span><a href="GHC.Rename.Env.html#FoundExactOrOrig"><span class="hs-identifier hs-var">FoundExactOrOrig</span></a></span><span> </span><span class="annot"><span class="annottext">(Name -&gt; ExactOrOrigResult) -&gt; RnM Name -&gt; RnM ExactOrOrigResult
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Module -&gt; OccName -&gt; RnM Name
forall a b. Module -&gt; OccName -&gt; TcRnIf a b Name
</span><a href="GHC.Iface.Env.html#lookupOrig"><span class="hs-identifier hs-var">lookupOrig</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107713"><span class="hs-identifier hs-var">rdr_mod</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107712"><span class="hs-identifier hs-var">rdr_occ</span></a></span><span>
</span><span id="line-447"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ExactOrOrigResult -&gt; RnM ExactOrOrigResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ExactOrOrigResult
</span><a href="GHC.Rename.Env.html#NotExactOrOrig"><span class="hs-identifier hs-var">NotExactOrOrig</span></a></span><span>
</span><span id="line-448"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-449"></span><span>    </span><span id="local-6989586621681107715"><span class="annot"><span class="annottext">cvtEither :: Either MsgDoc Name -&gt; ExactOrOrigResult
</span><a href="#local-6989586621681107715"><span class="hs-identifier hs-var hs-var">cvtEither</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681107710"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107710"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; ExactOrOrigResult
</span><a href="GHC.Rename.Env.html#ExactOrOrigError"><span class="hs-identifier hs-var">ExactOrOrigError</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107710"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-450"></span><span>    </span><span class="annot"><a href="#local-6989586621681107715"><span class="hs-identifier hs-var">cvtEither</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621681107709"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107709"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; ExactOrOrigResult
</span><a href="GHC.Rename.Env.html#FoundExactOrOrig"><span class="hs-identifier hs-var">FoundExactOrOrig</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107709"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-451"></span><span>
</span><span id="line-452"></span><span>
</span><span id="line-453"></span><span class="hs-comment">{- Note [Errors in lookup functions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Many of these lookup functions will attach an error if it can't find the Name it
is trying to lookup. However there are also _maybe and _either variants for many
of these functions.

These variants should *not* attach any errors, as there are
places where we want to attempt looking up a name, but it's not the end of the
world if we don't find it.

For example, see lookupThName_maybe: It calls lookupGlobalOccRn_maybe multiple
times for varying names in different namespaces. lookupGlobalOccRn_maybe should
therefore never attach an error, instead just return a Nothing.

For these _maybe/_either variant functions then, avoid calling further lookup
functions that can attach errors and instead call their _maybe/_either
counterparts.
-}</span><span>
</span><span id="line-471"></span><span>
</span><span id="line-472"></span><span class="hs-comment">-----------------------------------------------</span><span>
</span><span id="line-473"></span><span class="hs-comment">-- | Look up an occurrence of a field in record construction or pattern</span><span>
</span><span id="line-474"></span><span class="hs-comment">-- matching (but not update).  When the -XDisambiguateRecordFields</span><span>
</span><span id="line-475"></span><span class="hs-comment">-- flag is on, take account of the data constructor name to</span><span>
</span><span id="line-476"></span><span class="hs-comment">-- disambiguate which field to use.</span><span>
</span><span id="line-477"></span><span class="hs-comment">--</span><span>
</span><span id="line-478"></span><span class="hs-comment">-- See Note [DisambiguateRecordFields].</span><span>
</span><span id="line-479"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupRecFieldOcc"><span class="hs-identifier hs-type">lookupRecFieldOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-comment">-- Nothing  =&gt; just look it up as usual</span><span>
</span><span id="line-480"></span><span>                                </span><span class="hs-comment">-- Just con =&gt; use data con to disambiguate</span><span>
</span><span id="line-481"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span>
</span><span id="line-482"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-483"></span><span id="lookupRecFieldOcc"><span class="annot"><span class="annottext">lookupRecFieldOcc :: Maybe Name -&gt; RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupRecFieldOcc"><span class="hs-identifier hs-var hs-var">lookupRecFieldOcc</span></a></span></span><span> </span><span id="local-6989586621681107708"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107708"><span class="hs-identifier hs-var">mb_con</span></a></span></span><span> </span><span id="local-6989586621681107707"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107707"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-484"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107706"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107706"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107708"><span class="hs-identifier hs-var">mb_con</span></a></span><span>
</span><span id="line-485"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Builtin.Names.html#isUnboundName"><span class="hs-identifier hs-var">isUnboundName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107706"><span class="hs-identifier hs-var">con</span></a></span><span>  </span><span class="hs-comment">-- Avoid error cascade</span><span>
</span><span id="line-486"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; Name
</span><a href="GHC.Rename.Unbound.html#mkUnboundNameRdr"><span class="hs-identifier hs-var">mkUnboundNameRdr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107707"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-487"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107704"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107704"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107708"><span class="hs-identifier hs-var">mb_con</span></a></span><span>
</span><span id="line-488"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107703"><span class="annot"><span class="annottext">[FieldLabel]
</span><a href="#local-6989586621681107703"><span class="hs-identifier hs-var">flds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM [FieldLabel]
</span><a href="GHC.Rename.Env.html#lookupConstructorFields"><span class="hs-identifier hs-var">lookupConstructorFields</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107704"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-489"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681107702"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107702"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn GlobalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getGlobalRdrEnv"><span class="hs-identifier hs-var">getGlobalRdrEnv</span></a></span><span>
</span><span id="line-490"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107701"><span class="annot"><span class="annottext">lbl :: FieldLabelString
</span><a href="#local-6989586621681107701"><span class="hs-identifier hs-var hs-var">lbl</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; FieldLabelString
</span><a href="GHC.Types.Name.Occurrence.html#occNameFS"><span class="hs-identifier hs-var hs-var">occNameFS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#rdrNameOcc"><span class="hs-identifier hs-var">rdrNameOcc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107707"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-491"></span><span>             </span><span id="local-6989586621681107688"><span class="annot"><span class="annottext">mb_field :: Maybe (FieldLabel, GlobalRdrElt)
</span><a href="#local-6989586621681107688"><span class="hs-identifier hs-var hs-var">mb_field</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681107687"><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681107687"><span class="hs-identifier hs-var">fl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(FieldLabel -&gt; Bool) -&gt; [FieldLabel] -&gt; Maybe FieldLabel
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Maybe a
</span><a href="../../base/src/Data.Foldable.html#find"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">FieldLabelString -&gt; FieldLabelString -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">FieldLabelString
</span><a href="#local-6989586621681107701"><span class="hs-identifier hs-var">lbl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(FieldLabelString -&gt; Bool)
-&gt; (FieldLabel -&gt; FieldLabelString) -&gt; FieldLabel -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabel -&gt; FieldLabelString
forall a. FieldLbl a -&gt; FieldLabelString
</span><a href="GHC.Types.FieldLabel.html#flLabel"><span class="hs-identifier hs-var hs-var">flLabel</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[FieldLabel]
</span><a href="#local-6989586621681107703"><span class="hs-identifier hs-var">flds</span></a></span><span>
</span><span id="line-492"></span><span>                           </span><span class="hs-comment">-- We have the label, now check it is in</span><span>
</span><span id="line-493"></span><span>                           </span><span class="hs-comment">-- scope (with the correct qualifier if</span><span>
</span><span id="line-494"></span><span>                           </span><span class="hs-comment">-- there is one, hence calling pickGREs).</span><span>
</span><span id="line-495"></span><span>                           </span><span id="local-6989586621681107684"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107684"><span class="hs-identifier hs-var">gre</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv -&gt; FieldLabel -&gt; Maybe GlobalRdrElt
</span><a href="GHC.Types.Name.Reader.html#lookupGRE_FieldLabel"><span class="hs-identifier hs-var">lookupGRE_FieldLabel</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107702"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681107687"><span class="hs-identifier hs-var">fl</span></a></span><span>
</span><span id="line-496"></span><span>                           </span><span class="annot"><span class="annottext">Bool -&gt; Maybe ()
forall (f :: * -&gt; *). Alternative f =&gt; Bool -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier hs-var">guard</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#isQual"><span class="hs-identifier hs-var">isQual</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107707"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-497"></span><span>                                         </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
</span><a href="GHC.Types.Name.Reader.html#pickGREs"><span class="hs-identifier hs-var">pickGREs</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107707"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107684"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-498"></span><span>                           </span><span class="annot"><span class="annottext">(FieldLabel, GlobalRdrElt) -&gt; Maybe (FieldLabel, GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681107687"><span class="hs-identifier hs-var">fl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107684"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-499"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe (FieldLabel, GlobalRdrElt)
</span><a href="#local-6989586621681107688"><span class="hs-identifier hs-var">mb_field</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-500"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681107679"><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681107679"><span class="hs-identifier hs-var">fl</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681107678"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107678"><span class="hs-identifier hs-var">gre</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; GlobalRdrElt -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Env.html#addUsedGRE"><span class="hs-identifier hs-var">addUsedGRE</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107678"><span class="hs-identifier hs-var">gre</span></a></span><span>
</span><span id="line-501"></span><span>                                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FieldLabel -&gt; Name
forall a. FieldLbl a -&gt; a
</span><a href="GHC.Types.FieldLabel.html#flSelector"><span class="hs-identifier hs-var hs-var">flSelector</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681107679"><span class="hs-identifier hs-var">fl</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-502"></span><span>           </span><span class="annot"><span class="annottext">Maybe (FieldLabel, GlobalRdrElt)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupGlobalOccRn"><span class="hs-identifier hs-var">lookupGlobalOccRn</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107707"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-503"></span><span>             </span><span class="hs-comment">-- See Note [Fall back on lookupGlobalOccRn in lookupRecFieldOcc]</span><span>
</span><span id="line-504"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-505"></span><span>  </span><span class="hs-comment">-- This use of Global is right as we are looking up a selector which</span><span>
</span><span id="line-506"></span><span>  </span><span class="hs-comment">-- can only be defined at the top level.</span><span>
</span><span id="line-507"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupGlobalOccRn"><span class="hs-identifier hs-var">lookupGlobalOccRn</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107707"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-508"></span><span>
</span><span id="line-509"></span><span class="hs-comment">{- Note [DisambiguateRecordFields]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we are looking up record fields in record construction or pattern
matching, we can take advantage of the data constructor name to
resolve fields that would otherwise be ambiguous (provided the
-XDisambiguateRecordFields flag is on).

For example, consider:

   data S = MkS { x :: Int }
   data T = MkT { x :: Int }

   e = MkS { x = 3 }

When we are renaming the occurrence of `x` in `e`, instead of looking
`x` up directly (and finding both fields), lookupRecFieldOcc will
search the fields of `MkS` to find the only possible `x` the user can
mean.

Of course, we still have to check the field is in scope, using
lookupGRE_FieldLabel.  The handling of qualified imports is slightly
subtle: the occurrence may be unqualified even if the field is
imported only qualified (but if the occurrence is qualified, the
qualifier must be correct). For example:

   module A where
     data S = MkS { x :: Int }
     data T = MkT { x :: Int }

   module B where
     import qualified A (S(..))
     import A (T(MkT))

     e1 = MkT   { x = 3 }   -- x not in scope, so fail
     e2 = A.MkS { B.x = 3 } -- module qualifier is wrong, so fail
     e3 = A.MkS { x = 3 }   -- x in scope (lack of module qualifier permitted)

In case `e1`, lookupGRE_FieldLabel will return Nothing.  In case `e2`,
lookupGRE_FieldLabel will return the GRE for `A.x`, but then the guard
will fail because the field RdrName `B.x` is qualified and pickGREs
rejects the GRE.  In case `e3`, lookupGRE_FieldLabel will return the
GRE for `A.x` and the guard will succeed because the field RdrName `x`
is unqualified.


Note [Fall back on lookupGlobalOccRn in lookupRecFieldOcc]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Whenever we fail to find the field or it is not in scope, mb_field
will be False, and we fall back on looking it up normally using
lookupGlobalOccRn.  We don't report an error immediately because the
actual problem might be located elsewhere.  For example (#9975):

   data Test = Test { x :: Int }
   pattern Test wat = Test { x = wat }

Here there are multiple declarations of Test (as a data constructor
and as a pattern synonym), which will be reported as an error.  We
shouldn't also report an error about the occurrence of `x` in the
pattern synonym RHS.  However, if the pattern synonym gets added to
the environment first, we will try and fail to find `x` amongst the
(nonexistent) fields of the pattern synonym.

Alternatively, the scope check can fail due to Template Haskell.
Consider (#12130):

   module Foo where
     import M
     b = $(funny)

   module M(funny) where
     data T = MkT { x :: Int }
     funny :: Q Exp
     funny = [| MkT { x = 3 } |]

When we splice, `MkT` is not lexically in scope, so
lookupGRE_FieldLabel will fail.  But there is no need for
disambiguation anyway, because `x` is an original name, and
lookupGlobalOccRn will find it.
-}</span><span>
</span><span id="line-588"></span><span>
</span><span id="line-589"></span><span>
</span><span id="line-590"></span><span>
</span><span id="line-591"></span><span class="hs-comment">-- | Used in export lists to lookup the children.</span><span>
</span><span id="line-592"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupSubBndrOcc_helper"><span class="hs-identifier hs-type">lookupSubBndrOcc_helper</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span>
</span><span id="line-593"></span><span>                        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#ChildLookupResult"><span class="hs-identifier hs-type">ChildLookupResult</span></a></span><span>
</span><span id="line-594"></span><span id="lookupSubBndrOcc_helper"><span class="annot"><span class="annottext">lookupSubBndrOcc_helper :: Bool -&gt; Bool -&gt; Name -&gt; RdrName -&gt; RnM ChildLookupResult
</span><a href="GHC.Rename.Env.html#lookupSubBndrOcc_helper"><span class="hs-identifier hs-var hs-var">lookupSubBndrOcc_helper</span></a></span></span><span> </span><span id="local-6989586621681107676"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107676"><span class="hs-identifier hs-var">must_have_parent</span></a></span></span><span> </span><span id="local-6989586621681107675"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107675"><span class="hs-identifier hs-var">warn_if_deprec</span></a></span></span><span> </span><span id="local-6989586621681107674"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107674"><span class="hs-identifier hs-var">parent</span></a></span></span><span> </span><span id="local-6989586621681107673"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107673"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-595"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Builtin.Names.html#isUnboundName"><span class="hs-identifier hs-var">isUnboundName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107674"><span class="hs-identifier hs-var">parent</span></a></span><span>
</span><span id="line-596"></span><span>    </span><span class="hs-comment">-- Avoid an error cascade</span><span>
</span><span id="line-597"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ChildLookupResult -&gt; RnM ChildLookupResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Parent -&gt; Name -&gt; ChildLookupResult
</span><a href="GHC.Rename.Env.html#FoundName"><span class="hs-identifier hs-var">FoundName</span></a></span><span> </span><span class="annot"><span class="annottext">Parent
</span><a href="GHC.Types.Name.Reader.html#NoParent"><span class="hs-identifier hs-var">NoParent</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; Name
</span><a href="GHC.Rename.Unbound.html#mkUnboundNameRdr"><span class="hs-identifier hs-var">mkUnboundNameRdr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107673"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-598"></span><span>
</span><span id="line-599"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-600"></span><span>  </span><span id="local-6989586621681107670"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107670"><span class="hs-identifier hs-var">gre_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn GlobalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getGlobalRdrEnv"><span class="hs-identifier hs-var">getGlobalRdrEnv</span></a></span><span>
</span><span id="line-601"></span><span>
</span><span id="line-602"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107669"><span class="annot"><span class="annottext">original_gres :: [GlobalRdrElt]
</span><a href="#local-6989586621681107669"><span class="hs-identifier hs-var hs-var">original_gres</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv -&gt; OccName -&gt; [GlobalRdrElt]
</span><a href="GHC.Types.Name.Reader.html#lookupGlobalRdrEnv"><span class="hs-identifier hs-var">lookupGlobalRdrEnv</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107670"><span class="hs-identifier hs-var">gre_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#rdrNameOcc"><span class="hs-identifier hs-var">rdrNameOcc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107673"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-603"></span><span>  </span><span class="hs-comment">-- Disambiguate the lookup based on the parent information.</span><span>
</span><span id="line-604"></span><span>  </span><span class="hs-comment">-- The remaining GREs are things that we *could* export here, note that</span><span>
</span><span id="line-605"></span><span>  </span><span class="hs-comment">-- this includes things which have `NoParent`. Those are sorted in</span><span>
</span><span id="line-606"></span><span>  </span><span class="hs-comment">-- `checkPatSynParent`.</span><span>
</span><span id="line-607"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;parent&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107674"><span class="hs-identifier hs-var">parent</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-608"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupExportChild original_gres:&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107669"><span class="hs-identifier hs-var">original_gres</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-609"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupExportChild picked_gres:&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DisambigInfo -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; DisambigInfo
</span><a href="#local-6989586621681107668"><span class="hs-identifier hs-var">picked_gres</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107669"><span class="hs-identifier hs-var">original_gres</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107676"><span class="hs-identifier hs-var">must_have_parent</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-610"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; DisambigInfo
</span><a href="#local-6989586621681107668"><span class="hs-identifier hs-var">picked_gres</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107669"><span class="hs-identifier hs-var">original_gres</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-611"></span><span>    </span><span class="annot"><span class="annottext">DisambigInfo
</span><a href="GHC.Rename.Env.html#NoOccurrence"><span class="hs-identifier hs-var">NoOccurrence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-612"></span><span>      </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; RnM ChildLookupResult
</span><a href="#local-6989586621681107666"><span class="hs-identifier hs-var">noMatchingParentErr</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107669"><span class="hs-identifier hs-var">original_gres</span></a></span><span>
</span><span id="line-613"></span><span>    </span><span class="annot"><a href="GHC.Rename.Env.html#UniqueOccurrence"><span class="hs-identifier hs-type">UniqueOccurrence</span></a></span><span> </span><span id="local-6989586621681107664"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107664"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-614"></span><span>      </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107676"><span class="hs-identifier hs-var">must_have_parent</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; RnM ChildLookupResult
</span><a href="#local-6989586621681107666"><span class="hs-identifier hs-var">noMatchingParentErr</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107669"><span class="hs-identifier hs-var">original_gres</span></a></span><span>
</span><span id="line-615"></span><span>                          </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; RnM ChildLookupResult
</span><a href="#local-6989586621681107663"><span class="hs-identifier hs-var">checkFld</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107664"><span class="hs-identifier hs-var">g</span></a></span><span>
</span><span id="line-616"></span><span>    </span><span class="annot"><a href="GHC.Rename.Env.html#DisambiguatedOccurrence"><span class="hs-identifier hs-type">DisambiguatedOccurrence</span></a></span><span> </span><span id="local-6989586621681107661"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107661"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-617"></span><span>      </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; RnM ChildLookupResult
</span><a href="#local-6989586621681107663"><span class="hs-identifier hs-var">checkFld</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107661"><span class="hs-identifier hs-var">g</span></a></span><span>
</span><span id="line-618"></span><span>    </span><span class="annot"><a href="GHC.Rename.Env.html#AmbiguousOccurrence"><span class="hs-identifier hs-type">AmbiguousOccurrence</span></a></span><span> </span><span id="local-6989586621681107659"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107659"><span class="hs-identifier hs-var">gres</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-619"></span><span>      </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; RnM ChildLookupResult
</span><a href="#local-6989586621681107658"><span class="hs-identifier hs-var">mkNameClashErr</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107659"><span class="hs-identifier hs-var">gres</span></a></span><span>
</span><span id="line-620"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-621"></span><span>        </span><span class="hs-comment">-- Convert into FieldLabel if necessary</span><span>
</span><span id="line-622"></span><span>        </span><span class="annot"><a href="#local-6989586621681107663"><span class="hs-identifier hs-type">checkFld</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#ChildLookupResult"><span class="hs-identifier hs-type">ChildLookupResult</span></a></span><span>
</span><span id="line-623"></span><span>        </span><span id="local-6989586621681107663"><span class="annot"><span class="annottext">checkFld :: GlobalRdrElt -&gt; RnM ChildLookupResult
</span><a href="#local-6989586621681107663"><span class="hs-identifier hs-var hs-var">checkFld</span></a></span></span><span> </span><span id="local-6989586621681107657"><span class="annot"><span class="annottext">g :: GlobalRdrElt
</span><a href="#local-6989586621681107657"><span class="hs-identifier hs-var">g</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.Types.Name.Reader.html#GRE"><span class="hs-identifier hs-type">GRE</span></a></span><span class="hs-special">{</span><span id="local-6989586621681107655"><span class="annot"><span class="annottext">Name
gre_name :: Name
gre_name :: GlobalRdrElt -&gt; Name
</span><a href="#local-6989586621681107655"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681107654"><span class="annot"><span class="annottext">Parent
gre_par :: GlobalRdrElt -&gt; Parent
gre_par :: Parent
</span><a href="GHC.Types.Name.Reader.html#gre_par"><span class="hs-identifier hs-var hs-var">gre_par</span></a></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-624"></span><span>          </span><span class="annot"><span class="annottext">Bool -&gt; GlobalRdrElt -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Env.html#addUsedGRE"><span class="hs-identifier hs-var">addUsedGRE</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107675"><span class="hs-identifier hs-var">warn_if_deprec</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107657"><span class="hs-identifier hs-var">g</span></a></span><span>
</span><span id="line-625"></span><span>          </span><span class="annot"><span class="annottext">ChildLookupResult -&gt; RnM ChildLookupResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(ChildLookupResult -&gt; RnM ChildLookupResult)
-&gt; ChildLookupResult -&gt; RnM ChildLookupResult
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Parent
</span><a href="#local-6989586621681107654"><span class="hs-identifier hs-var">gre_par</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-626"></span><span>            </span><span class="annot"><a href="GHC.Types.Name.Reader.html#FldParent"><span class="hs-identifier hs-type">FldParent</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681107651"><span class="annot"><span class="annottext">Maybe FieldLabelString
</span><a href="#local-6989586621681107651"><span class="hs-identifier hs-var">mfs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-627"></span><span>              </span><span class="annot"><span class="annottext">FieldLabel -&gt; ChildLookupResult
</span><a href="GHC.Rename.Env.html#FoundFL"><span class="hs-identifier hs-var">FoundFL</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Maybe FieldLabelString -&gt; FieldLabel
</span><a href="#local-6989586621681107649"><span class="hs-identifier hs-var">fldParentToFieldLabel</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107655"><span class="hs-identifier hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe FieldLabelString
</span><a href="#local-6989586621681107651"><span class="hs-identifier hs-var">mfs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-628"></span><span>            </span><span class="annot"><span class="annottext">Parent
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Parent -&gt; Name -&gt; ChildLookupResult
</span><a href="GHC.Rename.Env.html#FoundName"><span class="hs-identifier hs-var">FoundName</span></a></span><span> </span><span class="annot"><span class="annottext">Parent
</span><a href="#local-6989586621681107654"><span class="hs-identifier hs-var">gre_par</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107655"><span class="hs-identifier hs-var">gre_name</span></a></span><span>
</span><span id="line-629"></span><span>
</span><span id="line-630"></span><span>        </span><span class="annot"><a href="#local-6989586621681107649"><span class="hs-identifier hs-type">fldParentToFieldLabel</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.FieldLabel.html#FieldLabel"><span class="hs-identifier hs-type">FieldLabel</span></a></span><span>
</span><span id="line-631"></span><span>        </span><span id="local-6989586621681107649"><span class="annot"><span class="annottext">fldParentToFieldLabel :: Name -&gt; Maybe FieldLabelString -&gt; FieldLabel
</span><a href="#local-6989586621681107649"><span class="hs-identifier hs-var hs-var">fldParentToFieldLabel</span></a></span></span><span> </span><span id="local-6989586621681107647"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107647"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681107646"><span class="annot"><span class="annottext">Maybe FieldLabelString
</span><a href="#local-6989586621681107646"><span class="hs-identifier hs-var">mfs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-632"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe FieldLabelString
</span><a href="#local-6989586621681107646"><span class="hs-identifier hs-var">mfs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-633"></span><span>            </span><span class="annot"><span class="annottext">Maybe FieldLabelString
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-634"></span><span>              </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107645"><span class="annot"><span class="annottext">fs :: FieldLabelString
</span><a href="#local-6989586621681107645"><span class="hs-identifier hs-var hs-var">fs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; FieldLabelString
</span><a href="GHC.Types.Name.Occurrence.html#occNameFS"><span class="hs-identifier hs-var hs-var">occNameFS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107647"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-635"></span><span>              </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">FieldLabelString -&gt; Bool -&gt; Name -&gt; FieldLabel
forall a. FieldLabelString -&gt; Bool -&gt; a -&gt; FieldLbl a
</span><a href="GHC.Types.FieldLabel.html#FieldLabel"><span class="hs-identifier hs-var">FieldLabel</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabelString
</span><a href="#local-6989586621681107645"><span class="hs-identifier hs-var">fs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107647"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-636"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107643"><span class="annot"><span class="annottext">FieldLabelString
</span><a href="#local-6989586621681107643"><span class="hs-identifier hs-var">fs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FieldLabelString -&gt; Bool -&gt; Name -&gt; FieldLabel
forall a. FieldLabelString -&gt; Bool -&gt; a -&gt; FieldLbl a
</span><a href="GHC.Types.FieldLabel.html#FieldLabel"><span class="hs-identifier hs-var">FieldLabel</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabelString
</span><a href="#local-6989586621681107643"><span class="hs-identifier hs-var">fs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107647"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-637"></span><span>
</span><span id="line-638"></span><span>        </span><span class="hs-comment">-- Called when we find no matching GREs after disambiguation but</span><span>
</span><span id="line-639"></span><span>        </span><span class="hs-comment">-- there are three situations where this happens.</span><span>
</span><span id="line-640"></span><span>        </span><span class="hs-comment">-- 1. There were none to begin with.</span><span>
</span><span id="line-641"></span><span>        </span><span class="hs-comment">-- 2. None of the matching ones were the parent but</span><span>
</span><span id="line-642"></span><span>        </span><span class="hs-comment">--  a. They were from an overloaded record field so we can report</span><span>
</span><span id="line-643"></span><span>        </span><span class="hs-comment">--     a better error</span><span>
</span><span id="line-644"></span><span>        </span><span class="hs-comment">--  b. The original lookup was actually ambiguous.</span><span>
</span><span id="line-645"></span><span>        </span><span class="hs-comment">--     For example, the case where overloading is off and two</span><span>
</span><span id="line-646"></span><span>        </span><span class="hs-comment">--     record fields are in scope from different record</span><span>
</span><span id="line-647"></span><span>        </span><span class="hs-comment">--     constructors, neither of which is the parent.</span><span>
</span><span id="line-648"></span><span>        </span><span class="annot"><a href="#local-6989586621681107666"><span class="hs-identifier hs-type">noMatchingParentErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#ChildLookupResult"><span class="hs-identifier hs-type">ChildLookupResult</span></a></span><span>
</span><span id="line-649"></span><span>        </span><span id="local-6989586621681107666"><span class="annot"><span class="annottext">noMatchingParentErr :: [GlobalRdrElt] -&gt; RnM ChildLookupResult
</span><a href="#local-6989586621681107666"><span class="hs-identifier hs-var hs-var">noMatchingParentErr</span></a></span></span><span> </span><span id="local-6989586621681107642"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107642"><span class="hs-identifier hs-var">original_gres</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-650"></span><span>          </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;npe&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107642"><span class="hs-identifier hs-var">original_gres</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-651"></span><span>          </span><span id="local-6989586621681107641"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107641"><span class="hs-identifier hs-var">overload_ok</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#DuplicateRecordFields"><span class="hs-identifier hs-var">LangExt.DuplicateRecordFields</span></a></span><span>
</span><span id="line-652"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107642"><span class="hs-identifier hs-var">original_gres</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-653"></span><span>            </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span>  </span><span class="annot"><span class="annottext">ChildLookupResult -&gt; RnM ChildLookupResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ChildLookupResult
</span><a href="GHC.Rename.Env.html#NameNotFound"><span class="hs-identifier hs-var">NameNotFound</span></a></span><span>
</span><span id="line-654"></span><span>            </span><span class="hs-special">[</span><span id="local-6989586621681107638"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107638"><span class="hs-identifier hs-var">g</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ChildLookupResult -&gt; RnM ChildLookupResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(ChildLookupResult -&gt; RnM ChildLookupResult)
-&gt; ChildLookupResult -&gt; RnM ChildLookupResult
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name -&gt; MsgDoc -&gt; [Name] -&gt; ChildLookupResult
</span><a href="GHC.Rename.Env.html#IncorrectParent"><span class="hs-identifier hs-var">IncorrectParent</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107674"><span class="hs-identifier hs-var">parent</span></a></span><span>
</span><span id="line-655"></span><span>                              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107638"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">(Name -&gt; MsgDoc) -&gt; Name -&gt; MsgDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107638"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-656"></span><span>                              </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107636"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107636"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107636"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Maybe Name
</span><a href="#local-6989586621681107635"><span class="hs-identifier hs-var">getParent</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107638"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">]</span><span class="hs-special">]</span><span>
</span><span id="line-657"></span><span>            </span><span id="local-6989586621681107634"><span class="annot"><span class="annottext">gss :: [GlobalRdrElt]
</span><a href="#local-6989586621681107634"><span class="hs-identifier hs-var">gss</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621681107633"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107633"><span class="hs-identifier hs-var">g</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">GlobalRdrElt
</span><span class="hs-identifier">_</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-658"></span><span>              </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Bool) -&gt; [GlobalRdrElt] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#isRecFldGRE"><span class="hs-identifier hs-var">isRecFldGRE</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107634"><span class="hs-identifier hs-var">gss</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107641"><span class="hs-identifier hs-var">overload_ok</span></a></span><span>
</span><span id="line-659"></span><span>                </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">ChildLookupResult -&gt; RnM ChildLookupResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(ChildLookupResult -&gt; RnM ChildLookupResult)
-&gt; ChildLookupResult -&gt; RnM ChildLookupResult
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-660"></span><span>                      </span><span class="annot"><span class="annottext">Name -&gt; Name -&gt; MsgDoc -&gt; [Name] -&gt; ChildLookupResult
</span><a href="GHC.Rename.Env.html#IncorrectParent"><span class="hs-identifier hs-var">IncorrectParent</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107674"><span class="hs-identifier hs-var">parent</span></a></span><span>
</span><span id="line-661"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107633"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-662"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FieldLabelString -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">(FieldLabelString -&gt; MsgDoc) -&gt; FieldLabelString -&gt; MsgDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe FieldLabelString -&gt; FieldLabelString
forall a. HasCallStack =&gt; String -&gt; Maybe a -&gt; a
</span><a href="GHC.Data.Maybe.html#expectJust"><span class="hs-identifier hs-var">expectJust</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;noMatchingParentErr&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Maybe FieldLabelString
</span><a href="GHC.Types.Name.Reader.html#greLabel"><span class="hs-identifier hs-var">greLabel</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107633"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-663"></span><span>                        </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107628"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681107627"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107627"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107634"><span class="hs-identifier hs-var">gss</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107628"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107628"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Maybe Name
</span><a href="#local-6989586621681107635"><span class="hs-identifier hs-var">getParent</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107627"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">]</span><span class="hs-special">]</span><span>
</span><span id="line-664"></span><span>                </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; RnM ChildLookupResult
</span><a href="#local-6989586621681107658"><span class="hs-identifier hs-var">mkNameClashErr</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107634"><span class="hs-identifier hs-var">gss</span></a></span><span>
</span><span id="line-665"></span><span>
</span><span id="line-666"></span><span>        </span><span class="annot"><a href="#local-6989586621681107658"><span class="hs-identifier hs-type">mkNameClashErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#ChildLookupResult"><span class="hs-identifier hs-type">ChildLookupResult</span></a></span><span>
</span><span id="line-667"></span><span>        </span><span id="local-6989586621681107658"><span class="annot"><span class="annottext">mkNameClashErr :: [GlobalRdrElt] -&gt; RnM ChildLookupResult
</span><a href="#local-6989586621681107658"><span class="hs-identifier hs-var hs-var">mkNameClashErr</span></a></span></span><span> </span><span id="local-6989586621681107626"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107626"><span class="hs-identifier hs-var">gres</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-668"></span><span>          </span><span class="annot"><span class="annottext">RdrName -&gt; [GlobalRdrElt] -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Utils.html#addNameClashErrRn"><span class="hs-identifier hs-var">addNameClashErrRn</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107673"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107626"><span class="hs-identifier hs-var">gres</span></a></span><span>
</span><span id="line-669"></span><span>          </span><span class="annot"><span class="annottext">ChildLookupResult -&gt; RnM ChildLookupResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Parent -&gt; Name -&gt; ChildLookupResult
</span><a href="GHC.Rename.Env.html#FoundName"><span class="hs-identifier hs-var">FoundName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Parent
</span><a href="GHC.Types.Name.Reader.html#gre_par"><span class="hs-identifier hs-var hs-var">gre_par</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; GlobalRdrElt
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107626"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; GlobalRdrElt
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107626"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-670"></span><span>
</span><span id="line-671"></span><span>        </span><span class="annot"><a href="#local-6989586621681107635"><span class="hs-identifier hs-type">getParent</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-672"></span><span>        </span><span id="local-6989586621681107635"><span class="annot"><span class="annottext">getParent :: GlobalRdrElt -&gt; Maybe Name
</span><a href="#local-6989586621681107635"><span class="hs-identifier hs-var hs-var">getParent</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.Reader.html#GRE"><span class="hs-identifier hs-type">GRE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">gre_par :: GlobalRdrElt -&gt; Parent
</span><a href="GHC.Types.Name.Reader.html#gre_par"><span class="hs-identifier hs-var">gre_par</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681107623"><span class="annot"><span class="annottext">Parent
</span><a href="#local-6989586621681107623"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-673"></span><span>          </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Parent
</span><a href="#local-6989586621681107623"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-674"></span><span>            </span><span class="annot"><a href="GHC.Types.Name.Reader.html#ParentIs"><span class="hs-identifier hs-type">ParentIs</span></a></span><span> </span><span id="local-6989586621681107621"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107621"><span class="hs-identifier hs-var">cur_parent</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Maybe Name
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107621"><span class="hs-identifier hs-var">cur_parent</span></a></span><span>
</span><span id="line-675"></span><span>            </span><span class="annot"><a href="GHC.Types.Name.Reader.html#FldParent"><span class="hs-identifier hs-type">FldParent</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">par_is :: Parent -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#par_is"><span class="hs-identifier hs-var">par_is</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681107619"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107619"><span class="hs-identifier hs-var">cur_parent</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Maybe Name
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107619"><span class="hs-identifier hs-var">cur_parent</span></a></span><span>
</span><span id="line-676"></span><span>            </span><span class="annot"><span class="annottext">Parent
</span><a href="GHC.Types.Name.Reader.html#NoParent"><span class="hs-identifier hs-var">NoParent</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Name
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-677"></span><span>
</span><span id="line-678"></span><span>        </span><span class="annot"><a href="#local-6989586621681107668"><span class="hs-identifier hs-type">picked_gres</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#DisambigInfo"><span class="hs-identifier hs-type">DisambigInfo</span></a></span><span>
</span><span id="line-679"></span><span>        </span><span class="hs-comment">-- For Unqual, find GREs that are in scope qualified or unqualified</span><span>
</span><span id="line-680"></span><span>        </span><span class="hs-comment">-- For Qual,   find GREs that are in scope with that qualification</span><span>
</span><span id="line-681"></span><span>        </span><span id="local-6989586621681107668"><span class="annot"><span class="annottext">picked_gres :: [GlobalRdrElt] -&gt; DisambigInfo
</span><a href="#local-6989586621681107668"><span class="hs-identifier hs-var hs-var">picked_gres</span></a></span></span><span> </span><span id="local-6989586621681107618"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107618"><span class="hs-identifier hs-var">gres</span></a></span></span><span>
</span><span id="line-682"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#isUnqual"><span class="hs-identifier hs-var">isUnqual</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107673"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-683"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[DisambigInfo] -&gt; DisambigInfo
forall a. Monoid a =&gt; [a] -&gt; a
</span><a href="../../base/src/GHC.Base.html#mconcat"><span class="hs-identifier hs-var">mconcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; DisambigInfo) -&gt; [GlobalRdrElt] -&gt; [DisambigInfo]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; DisambigInfo
</span><a href="#local-6989586621681107616"><span class="hs-identifier hs-var">right_parent</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107618"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-684"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-685"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[DisambigInfo] -&gt; DisambigInfo
forall a. Monoid a =&gt; [a] -&gt; a
</span><a href="../../base/src/GHC.Base.html#mconcat"><span class="hs-identifier hs-var">mconcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; DisambigInfo) -&gt; [GlobalRdrElt] -&gt; [DisambigInfo]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; DisambigInfo
</span><a href="#local-6989586621681107616"><span class="hs-identifier hs-var">right_parent</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
</span><a href="GHC.Types.Name.Reader.html#pickGREs"><span class="hs-identifier hs-var">pickGREs</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107673"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107618"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-686"></span><span>
</span><span id="line-687"></span><span>        </span><span class="annot"><a href="#local-6989586621681107616"><span class="hs-identifier hs-type">right_parent</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#DisambigInfo"><span class="hs-identifier hs-type">DisambigInfo</span></a></span><span>
</span><span id="line-688"></span><span>        </span><span id="local-6989586621681107616"><span class="annot"><span class="annottext">right_parent :: GlobalRdrElt -&gt; DisambigInfo
</span><a href="#local-6989586621681107616"><span class="hs-identifier hs-var hs-var">right_parent</span></a></span></span><span> </span><span id="local-6989586621681107615"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107615"><span class="hs-identifier hs-var">p</span></a></span></span><span>
</span><span id="line-689"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Maybe Name
</span><a href="#local-6989586621681107635"><span class="hs-identifier hs-var">getParent</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107615"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-690"></span><span>               </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107614"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107614"><span class="hs-identifier hs-var">cur_parent</span></a></span></span><span>
</span><span id="line-691"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107674"><span class="hs-identifier hs-var">parent</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107614"><span class="hs-identifier hs-var">cur_parent</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; DisambigInfo
</span><a href="GHC.Rename.Env.html#DisambiguatedOccurrence"><span class="hs-identifier hs-var">DisambiguatedOccurrence</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107615"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-692"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">DisambigInfo
</span><a href="GHC.Rename.Env.html#NoOccurrence"><span class="hs-identifier hs-var">NoOccurrence</span></a></span><span>
</span><span id="line-693"></span><span>               </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; DisambigInfo
</span><a href="GHC.Rename.Env.html#UniqueOccurrence"><span class="hs-identifier hs-var">UniqueOccurrence</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107615"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-694"></span><span>
</span><span id="line-695"></span><span>
</span><span id="line-696"></span><span class="hs-comment">-- This domain specific datatype is used to record why we decided it was</span><span>
</span><span id="line-697"></span><span class="hs-comment">-- possible that a GRE could be exported with a parent.</span><span>
</span><span id="line-698"></span><span class="hs-keyword">data</span><span> </span><span id="DisambigInfo"><span class="annot"><a href="GHC.Rename.Env.html#DisambigInfo"><span class="hs-identifier hs-var">DisambigInfo</span></a></span></span><span>
</span><span id="line-699"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span id="NoOccurrence"><span class="annot"><a href="GHC.Rename.Env.html#NoOccurrence"><span class="hs-identifier hs-var">NoOccurrence</span></a></span></span><span>
</span><span id="line-700"></span><span>          </span><span class="hs-comment">-- The GRE could never be exported. It has the wrong parent.</span><span>
</span><span id="line-701"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span id="UniqueOccurrence"><span class="annot"><a href="GHC.Rename.Env.html#UniqueOccurrence"><span class="hs-identifier hs-var">UniqueOccurrence</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span>
</span><span id="line-702"></span><span>          </span><span class="hs-comment">-- The GRE has no parent. It could be a pattern synonym.</span><span>
</span><span id="line-703"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span id="DisambiguatedOccurrence"><span class="annot"><a href="GHC.Rename.Env.html#DisambiguatedOccurrence"><span class="hs-identifier hs-var">DisambiguatedOccurrence</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span>
</span><span id="line-704"></span><span>          </span><span class="hs-comment">-- The parent of the GRE is the correct parent</span><span>
</span><span id="line-705"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span id="AmbiguousOccurrence"><span class="annot"><a href="GHC.Rename.Env.html#AmbiguousOccurrence"><span class="hs-identifier hs-var">AmbiguousOccurrence</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-706"></span><span>          </span><span class="hs-comment">-- For example, two normal identifiers with the same name are in</span><span>
</span><span id="line-707"></span><span>          </span><span class="hs-comment">-- scope. They will both be resolved to &quot;UniqueOccurrence&quot; and the</span><span>
</span><span id="line-708"></span><span>          </span><span class="hs-comment">-- monoid will combine them to this failing case.</span><span>
</span><span id="line-709"></span><span>
</span><span id="line-710"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681107611"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#DisambigInfo"><span class="hs-identifier hs-type">DisambigInfo</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-711"></span><span>  </span><span id="local-6989586621681107606"><span class="annot"><span class="annottext">ppr :: DisambigInfo -&gt; MsgDoc
</span><a href="#local-6989586621681107606"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="annot"><span class="annottext">DisambigInfo
</span><a href="GHC.Rename.Env.html#NoOccurrence"><span class="hs-identifier hs-var">NoOccurrence</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;NoOccurence&quot;</span></span><span>
</span><span id="line-712"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#UniqueOccurrence"><span class="hs-identifier hs-type">UniqueOccurrence</span></a></span><span> </span><span id="local-6989586621681107605"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107605"><span class="hs-identifier hs-var">gre</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;UniqueOccurrence:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107605"><span class="hs-identifier hs-var">gre</span></a></span><span>
</span><span id="line-713"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#DisambiguatedOccurrence"><span class="hs-identifier hs-type">DisambiguatedOccurrence</span></a></span><span> </span><span id="local-6989586621681107604"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107604"><span class="hs-identifier hs-var">gre</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DiambiguatedOccurrence:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107604"><span class="hs-identifier hs-var">gre</span></a></span><span>
</span><span id="line-714"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#AmbiguousOccurrence"><span class="hs-identifier hs-type">AmbiguousOccurrence</span></a></span><span> </span><span id="local-6989586621681107603"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107603"><span class="hs-identifier hs-var">gres</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Ambiguous:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107603"><span class="hs-identifier hs-var">gres</span></a></span><span>
</span><span id="line-715"></span><span>
</span><span id="line-716"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681107598"><span id="local-6989586621681107600"><span class="annot"><a href="../../base/src/GHC.Base.html#Semigroup"><span class="hs-identifier hs-type">Semi.Semigroup</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#DisambigInfo"><span class="hs-identifier hs-type">DisambigInfo</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-717"></span><span>  </span><span class="hs-comment">-- This is the key line: We prefer disambiguated occurrences to other</span><span>
</span><span id="line-718"></span><span>  </span><span class="hs-comment">-- names.</span><span>
</span><span id="line-719"></span><span>  </span><span class="annot"><span class="annottext">DisambigInfo
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681107596"><span class="annot"><span class="annottext">&lt;&gt; :: DisambigInfo -&gt; DisambigInfo -&gt; DisambigInfo
</span><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">&lt;&gt;</span></a></span></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#DisambiguatedOccurrence"><span class="hs-identifier hs-type">DisambiguatedOccurrence</span></a></span><span> </span><span id="local-6989586621681107595"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107595"><span class="hs-identifier hs-var">g'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; DisambigInfo
</span><a href="GHC.Rename.Env.html#DisambiguatedOccurrence"><span class="hs-identifier hs-var">DisambiguatedOccurrence</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107595"><span class="hs-identifier hs-var">g'</span></a></span><span>
</span><span id="line-720"></span><span>  </span><span class="annot"><a href="GHC.Rename.Env.html#DisambiguatedOccurrence"><span class="hs-identifier hs-type">DisambiguatedOccurrence</span></a></span><span> </span><span id="local-6989586621681107594"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107594"><span class="hs-identifier hs-var">g'</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">DisambigInfo
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; DisambigInfo
</span><a href="GHC.Rename.Env.html#DisambiguatedOccurrence"><span class="hs-identifier hs-var">DisambiguatedOccurrence</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107594"><span class="hs-identifier hs-var">g'</span></a></span><span>
</span><span id="line-721"></span><span>
</span><span id="line-722"></span><span>  </span><span class="annot"><span class="annottext">DisambigInfo
</span><a href="GHC.Rename.Env.html#NoOccurrence"><span class="hs-identifier hs-var">NoOccurrence</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span id="local-6989586621681107593"><span class="annot"><span class="annottext">DisambigInfo
</span><a href="#local-6989586621681107593"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DisambigInfo
</span><a href="#local-6989586621681107593"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-723"></span><span>  </span><span id="local-6989586621681107592"><span class="annot"><span class="annottext">DisambigInfo
</span><a href="#local-6989586621681107592"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">DisambigInfo
</span><a href="GHC.Rename.Env.html#NoOccurrence"><span class="hs-identifier hs-var">NoOccurrence</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DisambigInfo
</span><a href="#local-6989586621681107592"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-724"></span><span>  </span><span class="annot"><a href="GHC.Rename.Env.html#UniqueOccurrence"><span class="hs-identifier hs-type">UniqueOccurrence</span></a></span><span> </span><span id="local-6989586621681107591"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107591"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#UniqueOccurrence"><span class="hs-identifier hs-type">UniqueOccurrence</span></a></span><span> </span><span id="local-6989586621681107590"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107590"><span class="hs-identifier hs-var">g'</span></a></span></span><span>
</span><span id="line-725"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; DisambigInfo
</span><a href="GHC.Rename.Env.html#AmbiguousOccurrence"><span class="hs-identifier hs-var">AmbiguousOccurrence</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107591"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107590"><span class="hs-identifier hs-var">g'</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-726"></span><span>  </span><span class="annot"><a href="GHC.Rename.Env.html#UniqueOccurrence"><span class="hs-identifier hs-type">UniqueOccurrence</span></a></span><span> </span><span id="local-6989586621681107589"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107589"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#AmbiguousOccurrence"><span class="hs-identifier hs-type">AmbiguousOccurrence</span></a></span><span> </span><span id="local-6989586621681107588"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107588"><span class="hs-identifier hs-var">gs</span></a></span></span><span>
</span><span id="line-727"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; DisambigInfo
</span><a href="GHC.Rename.Env.html#AmbiguousOccurrence"><span class="hs-identifier hs-var">AmbiguousOccurrence</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107589"><span class="hs-identifier hs-var">g</span></a></span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107588"><span class="hs-identifier hs-var">gs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-728"></span><span>  </span><span class="annot"><a href="GHC.Rename.Env.html#AmbiguousOccurrence"><span class="hs-identifier hs-type">AmbiguousOccurrence</span></a></span><span> </span><span id="local-6989586621681107587"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107587"><span class="hs-identifier hs-var">gs</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#UniqueOccurrence"><span class="hs-identifier hs-type">UniqueOccurrence</span></a></span><span> </span><span id="local-6989586621681107586"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107586"><span class="hs-identifier hs-var">g'</span></a></span></span><span>
</span><span id="line-729"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; DisambigInfo
</span><a href="GHC.Rename.Env.html#AmbiguousOccurrence"><span class="hs-identifier hs-var">AmbiguousOccurrence</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107586"><span class="hs-identifier hs-var">g'</span></a></span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107587"><span class="hs-identifier hs-var">gs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-730"></span><span>  </span><span class="annot"><a href="GHC.Rename.Env.html#AmbiguousOccurrence"><span class="hs-identifier hs-type">AmbiguousOccurrence</span></a></span><span> </span><span id="local-6989586621681107585"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107585"><span class="hs-identifier hs-var">gs</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#AmbiguousOccurrence"><span class="hs-identifier hs-type">AmbiguousOccurrence</span></a></span><span> </span><span id="local-6989586621681107584"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107584"><span class="hs-identifier hs-var">gs'</span></a></span></span><span>
</span><span id="line-731"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; DisambigInfo
</span><a href="GHC.Rename.Env.html#AmbiguousOccurrence"><span class="hs-identifier hs-var">AmbiguousOccurrence</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107585"><span class="hs-identifier hs-var">gs</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107584"><span class="hs-identifier hs-var">gs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-732"></span><span>
</span><span id="line-733"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681107578"><span class="annot"><a href="../../base/src/GHC.Base.html#Monoid"><span class="hs-identifier hs-type">Monoid</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#DisambigInfo"><span class="hs-identifier hs-type">DisambigInfo</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-734"></span><span>  </span><span id="local-6989586621681107576"><span class="annot"><span class="annottext">mempty :: DisambigInfo
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var hs-var hs-var hs-var">mempty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DisambigInfo
</span><a href="GHC.Rename.Env.html#NoOccurrence"><span class="hs-identifier hs-var">NoOccurrence</span></a></span><span>
</span><span id="line-735"></span><span>  </span><span id="local-6989586621681107574"><span class="annot"><span class="annottext">mappend :: DisambigInfo -&gt; DisambigInfo -&gt; DisambigInfo
</span><a href="../../base/src/GHC.Base.html#mappend"><span class="hs-identifier hs-var hs-var hs-var hs-var">mappend</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DisambigInfo -&gt; DisambigInfo -&gt; DisambigInfo
forall a. Semigroup a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">(Semi.&lt;&gt;)</span></a></span><span>
</span><span id="line-736"></span><span>
</span><span id="line-737"></span><span class="hs-comment">-- Lookup SubBndrOcc can never be ambiguous</span><span>
</span><span id="line-738"></span><span class="hs-comment">--</span><span>
</span><span id="line-739"></span><span class="hs-comment">-- Records the result of looking up a child.</span><span>
</span><span id="line-740"></span><span class="hs-keyword">data</span><span> </span><span id="ChildLookupResult"><span class="annot"><a href="GHC.Rename.Env.html#ChildLookupResult"><span class="hs-identifier hs-var">ChildLookupResult</span></a></span></span><span>
</span><span id="line-741"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span id="NameNotFound"><span class="annot"><a href="GHC.Rename.Env.html#NameNotFound"><span class="hs-identifier hs-var">NameNotFound</span></a></span></span><span>                </span><span class="hs-comment">--  We couldn't find a suitable name</span><span>
</span><span id="line-742"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span id="IncorrectParent"><span class="annot"><a href="GHC.Rename.Env.html#IncorrectParent"><span class="hs-identifier hs-var">IncorrectParent</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>        </span><span class="hs-comment">-- Parent</span><span>
</span><span id="line-743"></span><span>                        </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>        </span><span class="hs-comment">-- Name of thing we were looking for</span><span>
</span><span id="line-744"></span><span>                        </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>        </span><span class="hs-comment">-- How to print the name</span><span>
</span><span id="line-745"></span><span>                        </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span>      </span><span class="hs-comment">-- List of possible parents</span><span>
</span><span id="line-746"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span id="FoundName"><span class="annot"><a href="GHC.Rename.Env.html#FoundName"><span class="hs-identifier hs-var">FoundName</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#Parent"><span class="hs-identifier hs-type">Parent</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>       </span><span class="hs-comment">--  We resolved to a normal name</span><span>
</span><span id="line-747"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span id="FoundFL"><span class="annot"><a href="GHC.Rename.Env.html#FoundFL"><span class="hs-identifier hs-var">FoundFL</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.FieldLabel.html#FieldLabel"><span class="hs-identifier hs-type">FieldLabel</span></a></span><span>          </span><span class="hs-comment">--  We resolved to a FL</span><span>
</span><span id="line-748"></span><span>
</span><span id="line-749"></span><span class="hs-comment">-- | Specialised version of msum for RnM ChildLookupResult</span><span>
</span><span id="line-750"></span><span class="annot"><a href="GHC.Rename.Env.html#combineChildLookupResult"><span class="hs-identifier hs-type">combineChildLookupResult</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#ChildLookupResult"><span class="hs-identifier hs-type">ChildLookupResult</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#ChildLookupResult"><span class="hs-identifier hs-type">ChildLookupResult</span></a></span><span>
</span><span id="line-751"></span><span id="combineChildLookupResult"><span class="annot"><span class="annottext">combineChildLookupResult :: [RnM ChildLookupResult] -&gt; RnM ChildLookupResult
</span><a href="GHC.Rename.Env.html#combineChildLookupResult"><span class="hs-identifier hs-var hs-var">combineChildLookupResult</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ChildLookupResult -&gt; RnM ChildLookupResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ChildLookupResult
</span><a href="GHC.Rename.Env.html#NameNotFound"><span class="hs-identifier hs-var">NameNotFound</span></a></span><span>
</span><span id="line-752"></span><span class="annot"><a href="GHC.Rename.Env.html#combineChildLookupResult"><span class="hs-identifier hs-var">combineChildLookupResult</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681107573"><span class="annot"><span class="annottext">RnM ChildLookupResult
</span><a href="#local-6989586621681107573"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681107572"><span class="annot"><span class="annottext">[RnM ChildLookupResult]
</span><a href="#local-6989586621681107572"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-753"></span><span>  </span><span id="local-6989586621681107571"><span class="annot"><span class="annottext">ChildLookupResult
</span><a href="#local-6989586621681107571"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RnM ChildLookupResult
</span><a href="#local-6989586621681107573"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-754"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ChildLookupResult
</span><a href="#local-6989586621681107571"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-755"></span><span>    </span><span class="annot"><span class="annottext">ChildLookupResult
</span><a href="GHC.Rename.Env.html#NameNotFound"><span class="hs-identifier hs-var">NameNotFound</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[RnM ChildLookupResult] -&gt; RnM ChildLookupResult
</span><a href="GHC.Rename.Env.html#combineChildLookupResult"><span class="hs-identifier hs-var">combineChildLookupResult</span></a></span><span> </span><span class="annot"><span class="annottext">[RnM ChildLookupResult]
</span><a href="#local-6989586621681107572"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-756"></span><span>    </span><span class="annot"><span class="annottext">ChildLookupResult
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ChildLookupResult -&gt; RnM ChildLookupResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ChildLookupResult
</span><a href="#local-6989586621681107571"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-757"></span><span>
</span><span id="line-758"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681107568"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#ChildLookupResult"><span class="hs-identifier hs-type">ChildLookupResult</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-759"></span><span>  </span><span id="local-6989586621681107560"><span class="annot"><span class="annottext">ppr :: ChildLookupResult -&gt; MsgDoc
</span><a href="#local-6989586621681107560"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="annot"><span class="annottext">ChildLookupResult
</span><a href="GHC.Rename.Env.html#NameNotFound"><span class="hs-identifier hs-var">NameNotFound</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;NameNotFound&quot;</span></span><span>
</span><span id="line-760"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#FoundName"><span class="hs-identifier hs-type">FoundName</span></a></span><span> </span><span id="local-6989586621681107559"><span class="annot"><span class="annottext">Parent
</span><a href="#local-6989586621681107559"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621681107558"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107558"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Found:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Parent -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Parent
</span><a href="#local-6989586621681107559"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107558"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-761"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#FoundFL"><span class="hs-identifier hs-type">FoundFL</span></a></span><span> </span><span id="local-6989586621681107557"><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681107557"><span class="hs-identifier hs-var">fls</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;FoundFL:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabel -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681107557"><span class="hs-identifier hs-var">fls</span></a></span><span>
</span><span id="line-762"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#IncorrectParent"><span class="hs-identifier hs-type">IncorrectParent</span></a></span><span> </span><span id="local-6989586621681107556"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107556"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621681107555"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107555"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681107554"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107554"><span class="hs-identifier hs-var">td</span></a></span></span><span> </span><span id="local-6989586621681107553"><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107553"><span class="hs-identifier hs-var">ns</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;IncorrectParent&quot;</span></span><span>
</span><span id="line-763"></span><span>                                  </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107556"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107555"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107554"><span class="hs-identifier hs-var">td</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107553"><span class="hs-identifier hs-var">ns</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-764"></span><span>
</span><span id="line-765"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupSubBndrOcc"><span class="hs-identifier hs-type">lookupSubBndrOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-766"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>     </span><span class="hs-comment">-- Parent</span><span>
</span><span id="line-767"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-768"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span>
</span><span id="line-769"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-770"></span><span class="hs-comment">-- Find all the things the rdr-name maps to</span><span>
</span><span id="line-771"></span><span class="hs-comment">-- and pick the one with the right parent namep</span><span>
</span><span id="line-772"></span><span id="lookupSubBndrOcc"><span class="annot"><span class="annottext">lookupSubBndrOcc :: Bool -&gt; Name -&gt; MsgDoc -&gt; RdrName -&gt; RnM (Either MsgDoc Name)
</span><a href="GHC.Rename.Env.html#lookupSubBndrOcc"><span class="hs-identifier hs-var hs-var">lookupSubBndrOcc</span></a></span></span><span> </span><span id="local-6989586621681107551"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107551"><span class="hs-identifier hs-var">warn_if_deprec</span></a></span></span><span> </span><span id="local-6989586621681107550"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107550"><span class="hs-identifier hs-var">the_parent</span></a></span></span><span> </span><span id="local-6989586621681107549"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107549"><span class="hs-identifier hs-var">doc</span></a></span></span><span> </span><span id="local-6989586621681107548"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107548"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-773"></span><span>  </span><span id="local-6989586621681107547"><span class="annot"><span class="annottext">ChildLookupResult
</span><a href="#local-6989586621681107547"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-774"></span><span>    </span><span class="annot"><span class="annottext">RdrName
-&gt; (Name -&gt; ChildLookupResult)
-&gt; RnM ChildLookupResult
-&gt; RnM ChildLookupResult
forall r. RdrName -&gt; (Name -&gt; r) -&gt; RnM r -&gt; RnM r
</span><a href="GHC.Rename.Env.html#lookupExactOrOrig"><span class="hs-identifier hs-var">lookupExactOrOrig</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107548"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Parent -&gt; Name -&gt; ChildLookupResult
</span><a href="GHC.Rename.Env.html#FoundName"><span class="hs-identifier hs-var">FoundName</span></a></span><span> </span><span class="annot"><span class="annottext">Parent
</span><a href="GHC.Types.Name.Reader.html#NoParent"><span class="hs-identifier hs-var">NoParent</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(RnM ChildLookupResult -&gt; RnM ChildLookupResult)
-&gt; RnM ChildLookupResult -&gt; RnM ChildLookupResult
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-775"></span><span>      </span><span class="hs-comment">-- This happens for built-in classes, see mod052 for example</span><span>
</span><span id="line-776"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Name -&gt; RdrName -&gt; RnM ChildLookupResult
</span><a href="GHC.Rename.Env.html#lookupSubBndrOcc_helper"><span class="hs-identifier hs-var">lookupSubBndrOcc_helper</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107551"><span class="hs-identifier hs-var">warn_if_deprec</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107550"><span class="hs-identifier hs-var">the_parent</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107548"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-777"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ChildLookupResult
</span><a href="#local-6989586621681107547"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-778"></span><span>    </span><span class="annot"><span class="annottext">ChildLookupResult
</span><a href="GHC.Rename.Env.html#NameNotFound"><span class="hs-identifier hs-var">NameNotFound</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; Either MsgDoc Name
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; RdrName -&gt; MsgDoc
</span><a href="GHC.Rename.Utils.html#unknownSubordinateErr"><span class="hs-identifier hs-var">unknownSubordinateErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107549"><span class="hs-identifier hs-var">doc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107548"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-779"></span><span>    </span><span class="annot"><a href="GHC.Rename.Env.html#FoundName"><span class="hs-identifier hs-type">FoundName</span></a></span><span> </span><span id="local-6989586621681107545"><span class="annot"><span class="annottext">Parent
</span><a href="#local-6989586621681107545"><span class="hs-identifier hs-var">_p</span></a></span></span><span> </span><span id="local-6989586621681107544"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107544"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either MsgDoc Name
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107544"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-780"></span><span>    </span><span class="annot"><a href="GHC.Rename.Env.html#FoundFL"><span class="hs-identifier hs-type">FoundFL</span></a></span><span> </span><span id="local-6989586621681107543"><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681107543"><span class="hs-identifier hs-var">fl</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span>  </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either MsgDoc Name
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FieldLabel -&gt; Name
forall a. FieldLbl a -&gt; a
</span><a href="GHC.Types.FieldLabel.html#flSelector"><span class="hs-identifier hs-var hs-var">flSelector</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabel
</span><a href="#local-6989586621681107543"><span class="hs-identifier hs-var">fl</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-781"></span><span>    </span><span class="annot"><a href="GHC.Rename.Env.html#IncorrectParent"><span class="hs-identifier hs-type">IncorrectParent</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span>
</span><span id="line-782"></span><span>         </span><span class="hs-comment">-- See [Mismatched class methods and associated type families]</span><span>
</span><span id="line-783"></span><span>         </span><span class="hs-comment">-- in TcInstDecls.</span><span>
</span><span id="line-784"></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either MsgDoc Name -&gt; RnM (Either MsgDoc Name))
-&gt; Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Either MsgDoc Name
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; RdrName -&gt; MsgDoc
</span><a href="GHC.Rename.Utils.html#unknownSubordinateErr"><span class="hs-identifier hs-var">unknownSubordinateErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107549"><span class="hs-identifier hs-var">doc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107548"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-785"></span><span>
</span><span id="line-786"></span><span class="hs-comment">{-
Note [Family instance binders]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
  data family F a
  data instance F T = X1 | X2

The 'data instance' decl has an *occurrence* of F (and T), and *binds*
X1 and X2.  (This is unlike a normal data type declaration which would
bind F too.)  So we want an AvailTC F [X1,X2].

Now consider a similar pair:
  class C a where
    data G a
  instance C S where
    data G S = Y1 | Y2

The 'data G S' *binds* Y1 and Y2, and has an *occurrence* of G.

But there is a small complication: in an instance decl, we don't use
qualified names on the LHS; instead we use the class to disambiguate.
Thus:
  module M where
    import Blib( G )
    class C a where
      data G a
    instance C S where
      data G S = Y1 | Y2
Even though there are two G's in scope (M.G and Blib.G), the occurrence
of 'G' in the 'instance C S' decl is unambiguous, because C has only
one associated type called G. This is exactly what happens for methods,
and it is only consistent to do the same thing for types. That's the
role of the function lookupTcdName; the (Maybe Name) give the class of
the encloseing instance decl, if any.

Note [Looking up Exact RdrNames]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Exact RdrNames are generated by:

* Template Haskell (See Note [Binders in Template Haskell] in GHC.ThToHs)
* Derived instances (See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate)

For data types and classes have Exact system Names in the binding
positions for constructors, TyCons etc.  For example
    [d| data T = MkT Int |]
when we splice in and convert to HsSyn RdrName, we'll get
    data (Exact (system Name &quot;T&quot;)) = (Exact (system Name &quot;MkT&quot;)) ...
These System names are generated by GHC.ThToHs.thRdrName

But, constructors and the like need External Names, not System Names!
So we do the following

 * In GHC.Rename.Env.newTopSrcBinder we spot Exact RdrNames that wrap a
   non-External Name, and make an External name for it. This is
   the name that goes in the GlobalRdrEnv

 * When looking up an occurrence of an Exact name, done in
   GHC.Rename.Env.lookupExactOcc, we find the Name with the right unique in the
   GlobalRdrEnv, and use the one from the envt -- it will be an
   External Name in the case of the data type/constructor above.

 * Exact names are also use for purely local binders generated
   by TH, such as    \x_33. x_33
   Both binder and occurrence are Exact RdrNames.  The occurrence
   gets looked up in the LocalRdrEnv by GHC.Rename.Env.lookupOccRn, and
   misses, because lookupLocalRdrEnv always returns Nothing for
   an Exact Name.  Now we fall through to lookupExactOcc, which
   will find the Name is not in the GlobalRdrEnv, so we just use
   the Exact supplied Name.

Note [Splicing Exact names]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider the splice $(do { x &lt;- newName &quot;x&quot;; return (VarE x) })
This will generate a (HsExpr RdrName) term that mentions the
Exact RdrName &quot;x_56&quot; (or whatever), but does not bind it.  So
when looking such Exact names we want to check that it's in scope,
otherwise the type checker will get confused.  To do this we need to
keep track of all the Names in scope, and the LocalRdrEnv does just that;
we consult it with RdrName.inLocalRdrEnvScope.

There is another wrinkle.  With TH and -XDataKinds, consider
   $( [d| data Nat = Zero
          data T = MkT (Proxy 'Zero)  |] )
After splicing, but before renaming we get this:
   data Nat_77{tc} = Zero_78{d}
   data T_79{tc} = MkT_80{d} (Proxy 'Zero_78{tc})  |] )
The occurrence of 'Zero in the data type for T has the right unique,
but it has a TcClsName name-space in its OccName.  (This is set by
the ctxt_ns argument of Convert.thRdrName.)  When we check that is
in scope in the GlobalRdrEnv, we need to look up the DataName namespace
too.  (An alternative would be to make the GlobalRdrEnv also have
a Name -&gt; GRE mapping.)

Note [Template Haskell ambiguity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The GlobalRdrEnv invariant says that if
  occ -&gt; [gre1, ..., gren]
then the gres have distinct Names (INVARIANT 1 of GlobalRdrEnv).
This is guaranteed by extendGlobalRdrEnvRn (the dups check in add_gre).

So how can we get multiple gres in lookupExactOcc_maybe?  Because in
TH we might use the same TH NameU in two different name spaces.
eg (#7241):
   $(newName &quot;Foo&quot; &gt;&gt;= \o -&gt; return [DataD [] o [] [RecC o []] [''Show]])
Here we generate a type constructor and data constructor with the same
unique, but different name spaces.

It'd be nicer to rule this out in extendGlobalRdrEnvRn, but that would
mean looking up the OccName in every name-space, just in case, and that
seems a bit brutal.  So it's just done here on lookup.  But we might
need to revisit that choice.

Note [Usage for sub-bndrs]
~~~~~~~~~~~~~~~~~~~~~~~~~~
If you have this
   import qualified M( C( f ) )
   instance M.C T where
     f x = x
then is the qualified import M.f used?  Obviously yes.
But the RdrName used in the instance decl is unqualified.  In effect,
we fill in the qualification by looking for f's whose class is M.C
But when adding to the UsedRdrNames we must make that qualification
explicit (saying &quot;used  M.f&quot;), otherwise we get &quot;Redundant import of M.f&quot;.

So we make up a suitable (fake) RdrName.  But be careful
   import qualified M
   import M( C(f) )
   instance C T where
     f x = x
Here we want to record a use of 'f', not of 'M.f', otherwise
we'll miss the fact that the qualified import is redundant.

--------------------------------------------------
--              Occurrences
--------------------------------------------------
-}</span><span>
</span><span id="line-922"></span><span>
</span><span id="line-923"></span><span>
</span><span id="line-924"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocatedOccRn"><span class="hs-identifier hs-type">lookupLocatedOccRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-925"></span><span id="lookupLocatedOccRn"><span class="annot"><span class="annottext">lookupLocatedOccRn :: Located RdrName -&gt; RnM (Located Name)
</span><a href="GHC.Rename.Env.html#lookupLocatedOccRn"><span class="hs-identifier hs-var hs-var">lookupLocatedOccRn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(RdrName -&gt; RnM Name) -&gt; Located RdrName -&gt; RnM (Located Name)
forall a b. (a -&gt; TcM b) -&gt; Located a -&gt; TcM (Located b)
</span><a href="GHC.Tc.Utils.Monad.html#wrapLocM"><span class="hs-identifier hs-var">wrapLocM</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupOccRn"><span class="hs-identifier hs-var">lookupOccRn</span></a></span><span>
</span><span id="line-926"></span><span>
</span><span id="line-927"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocalOccRn_maybe"><span class="hs-identifier hs-type">lookupLocalOccRn_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-928"></span><span class="hs-comment">-- Just look in the local environment</span><span>
</span><span id="line-929"></span><span id="lookupLocalOccRn_maybe"><span class="annot"><span class="annottext">lookupLocalOccRn_maybe :: RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupLocalOccRn_maybe"><span class="hs-identifier hs-var hs-var">lookupLocalOccRn_maybe</span></a></span></span><span> </span><span id="local-6989586621681107542"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107542"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-930"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107541"><span class="annot"><span class="annottext">LocalRdrEnv
</span><a href="#local-6989586621681107541"><span class="hs-identifier hs-var">local_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RnM LocalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getLocalRdrEnv"><span class="hs-identifier hs-var">getLocalRdrEnv</span></a></span><span>
</span><span id="line-931"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe Name -&gt; RnM (Maybe Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalRdrEnv -&gt; RdrName -&gt; Maybe Name
</span><a href="GHC.Types.Name.Reader.html#lookupLocalRdrEnv"><span class="hs-identifier hs-var">lookupLocalRdrEnv</span></a></span><span> </span><span class="annot"><span class="annottext">LocalRdrEnv
</span><a href="#local-6989586621681107541"><span class="hs-identifier hs-var">local_env</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107542"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-932"></span><span>
</span><span id="line-933"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocalOccThLvl_maybe"><span class="hs-identifier hs-type">lookupLocalOccThLvl_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#ThLevel"><span class="hs-identifier hs-type">ThLevel</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-934"></span><span class="hs-comment">-- Just look in the local environment</span><span>
</span><span id="line-935"></span><span id="lookupLocalOccThLvl_maybe"><span class="annot"><span class="annottext">lookupLocalOccThLvl_maybe :: Name -&gt; RnM (Maybe (TopLevelFlag, Arity))
</span><a href="GHC.Rename.Env.html#lookupLocalOccThLvl_maybe"><span class="hs-identifier hs-var hs-var">lookupLocalOccThLvl_maybe</span></a></span></span><span> </span><span id="local-6989586621681107538"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107538"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-936"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107537"><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681107537"><span class="hs-identifier hs-var">lcl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcLclEnv
forall gbl lcl. TcRnIf gbl lcl lcl
</span><a href="GHC.Tc.Utils.Monad.html#getLclEnv"><span class="hs-identifier hs-var">getLclEnv</span></a></span><span>
</span><span id="line-937"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe (TopLevelFlag, Arity) -&gt; RnM (Maybe (TopLevelFlag, Arity))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NameEnv (TopLevelFlag, Arity)
-&gt; Name -&gt; Maybe (TopLevelFlag, Arity)
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLclEnv -&gt; NameEnv (TopLevelFlag, Arity)
</span><a href="GHC.Tc.Types.html#tcl_th_bndrs"><span class="hs-identifier hs-var hs-var">tcl_th_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681107537"><span class="hs-identifier hs-var">lcl_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107538"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-938"></span><span>
</span><span id="line-939"></span><span class="hs-comment">-- lookupOccRn looks up an occurrence of a RdrName</span><span>
</span><span id="line-940"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupOccRn"><span class="hs-identifier hs-type">lookupOccRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-941"></span><span id="lookupOccRn"><span class="annot"><span class="annottext">lookupOccRn :: RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupOccRn"><span class="hs-identifier hs-var hs-var">lookupOccRn</span></a></span></span><span> </span><span id="local-6989586621681107534"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107534"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-942"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107533"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107533"><span class="hs-identifier hs-var">mb_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupOccRn_maybe"><span class="hs-identifier hs-var">lookupOccRn_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107534"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-943"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107533"><span class="hs-identifier hs-var">mb_name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-944"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107532"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107532"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107532"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-945"></span><span>           </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Unbound.html#reportUnboundName"><span class="hs-identifier hs-var">reportUnboundName</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107534"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-946"></span><span>
</span><span id="line-947"></span><span class="hs-comment">-- Only used in one place, to rename pattern synonym binders.</span><span>
</span><span id="line-948"></span><span class="hs-comment">-- See Note [Renaming pattern synonym variables] in GHC.Rename.Bind</span><span>
</span><span id="line-949"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocalOccRn"><span class="hs-identifier hs-type">lookupLocalOccRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-950"></span><span id="lookupLocalOccRn"><span class="annot"><span class="annottext">lookupLocalOccRn :: RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupLocalOccRn"><span class="hs-identifier hs-var hs-var">lookupLocalOccRn</span></a></span></span><span> </span><span id="local-6989586621681107530"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107530"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-951"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107529"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107529"><span class="hs-identifier hs-var">mb_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupLocalOccRn_maybe"><span class="hs-identifier hs-var">lookupLocalOccRn_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107530"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-952"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107529"><span class="hs-identifier hs-var">mb_name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-953"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107528"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107528"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107528"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-954"></span><span>           </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">WhereLooking -&gt; RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Unbound.html#unboundName"><span class="hs-identifier hs-var">unboundName</span></a></span><span> </span><span class="annot"><span class="annottext">WhereLooking
</span><a href="GHC.Rename.Unbound.html#WL_LocalOnly"><span class="hs-identifier hs-var">WL_LocalOnly</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107530"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-955"></span><span>
</span><span id="line-956"></span><span class="hs-comment">-- lookupTypeOccRn looks up an optionally promoted RdrName.</span><span>
</span><span id="line-957"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupTypeOccRn"><span class="hs-identifier hs-type">lookupTypeOccRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-958"></span><span class="hs-comment">-- see Note [Demotion]</span><span>
</span><span id="line-959"></span><span id="lookupTypeOccRn"><span class="annot"><span class="annottext">lookupTypeOccRn :: RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupTypeOccRn"><span class="hs-identifier hs-var hs-var">lookupTypeOccRn</span></a></span></span><span> </span><span id="local-6989586621681107526"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107526"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-960"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; Bool
</span><a href="GHC.Types.Name.Occurrence.html#isVarOcc"><span class="hs-identifier hs-var">isVarOcc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#rdrNameOcc"><span class="hs-identifier hs-var">rdrNameOcc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107526"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- See Note [Promoted variables in types]</span><span>
</span><span id="line-961"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#badVarInType"><span class="hs-identifier hs-var">badVarInType</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107526"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-962"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-963"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107523"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107523"><span class="hs-identifier hs-var">mb_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupOccRn_maybe"><span class="hs-identifier hs-var">lookupOccRn_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107526"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-964"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107523"><span class="hs-identifier hs-var">mb_name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-965"></span><span>             </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107522"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107522"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107522"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-966"></span><span>             </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookup_demoted"><span class="hs-identifier hs-var">lookup_demoted</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107526"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-967"></span><span>
</span><span id="line-968"></span><span class="annot"><a href="GHC.Rename.Env.html#lookup_demoted"><span class="hs-identifier hs-type">lookup_demoted</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-969"></span><span id="lookup_demoted"><span class="annot"><span class="annottext">lookup_demoted :: RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookup_demoted"><span class="hs-identifier hs-var hs-var">lookup_demoted</span></a></span></span><span> </span><span id="local-6989586621681107520"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107520"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-970"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107519"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107519"><span class="hs-identifier hs-var">demoted_rdr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; Maybe RdrName
</span><a href="GHC.Types.Name.Reader.html#demoteRdrName"><span class="hs-identifier hs-var">demoteRdrName</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107520"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-971"></span><span>    </span><span class="hs-comment">-- Maybe it's the name of a *data* constructor</span><span>
</span><span id="line-972"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107517"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107517"><span class="hs-identifier hs-var">data_kinds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#DataKinds"><span class="hs-identifier hs-var">LangExt.DataKinds</span></a></span><span>
</span><span id="line-973"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681107515"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107515"><span class="hs-identifier hs-var">star_is_type</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#StarIsType"><span class="hs-identifier hs-var">LangExt.StarIsType</span></a></span><span>
</span><span id="line-974"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107513"><span class="annot"><span class="annottext">star_info :: MsgDoc
</span><a href="#local-6989586621681107513"><span class="hs-identifier hs-var hs-var">star_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; RdrName -&gt; MsgDoc
</span><a href="GHC.Types.Name.Reader.html#starInfo"><span class="hs-identifier hs-var">starInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107515"><span class="hs-identifier hs-var">star_is_type</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107520"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-975"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107517"><span class="hs-identifier hs-var">data_kinds</span></a></span><span>
</span><span id="line-976"></span><span>            </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107511"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107511"><span class="hs-identifier hs-var">mb_demoted_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupOccRn_maybe"><span class="hs-identifier hs-var">lookupOccRn_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107519"><span class="hs-identifier hs-var">demoted_rdr</span></a></span><span>
</span><span id="line-977"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107511"><span class="hs-identifier hs-var">mb_demoted_name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-978"></span><span>                        </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">WhereLooking -&gt; RdrName -&gt; MsgDoc -&gt; RnM Name
</span><a href="GHC.Rename.Unbound.html#unboundNameX"><span class="hs-identifier hs-var">unboundNameX</span></a></span><span> </span><span class="annot"><span class="annottext">WhereLooking
</span><a href="GHC.Rename.Unbound.html#WL_Any"><span class="hs-identifier hs-var">WL_Any</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107520"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107513"><span class="hs-identifier hs-var">star_info</span></a></span><span>
</span><span id="line-979"></span><span>                        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107508"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107508"><span class="hs-identifier hs-var">demoted_name</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-980"></span><span>                          </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">WarningFlag
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall gbl lcl.
WarningFlag -&gt; TcRnIf gbl lcl () -&gt; TcRnIf gbl lcl ()
</span><a href="GHC.Tc.Utils.Monad.html#whenWOptM"><span class="hs-identifier hs-var">whenWOptM</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnUntickedPromotedConstructors"><span class="hs-identifier hs-var">Opt_WarnUntickedPromotedConstructors</span></a></span><span> </span><span class="annot"><span class="annottext">(IOEnv (Env TcGblEnv TcLclEnv) ()
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) ())
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-981"></span><span>                               </span><span class="annot"><span class="annottext">WarnReason -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addWarn"><span class="hs-identifier hs-var">addWarn</span></a></span><span>
</span><span id="line-982"></span><span>                                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WarningFlag -&gt; WarnReason
</span><a href="GHC.Driver.Flags.html#Reason"><span class="hs-identifier hs-var">Reason</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnUntickedPromotedConstructors"><span class="hs-identifier hs-var">Opt_WarnUntickedPromotedConstructors</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-983"></span><span>                                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="#local-6989586621681107503"><span class="hs-identifier hs-var">untickedPromConstrWarn</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107508"><span class="hs-identifier hs-var">demoted_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-984"></span><span>                             </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107508"><span class="hs-identifier hs-var">demoted_name</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-985"></span><span>            </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- We need to check if a data constructor of this name is</span><span>
</span><span id="line-986"></span><span>                      </span><span class="hs-comment">-- in scope to give good error messages. However, we do</span><span>
</span><span id="line-987"></span><span>                      </span><span class="hs-comment">-- not want to give an additional error if the data</span><span>
</span><span id="line-988"></span><span>                      </span><span class="hs-comment">-- constructor happens to be out of scope! See #13947.</span><span>
</span><span id="line-989"></span><span>                      </span><span id="local-6989586621681107502"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107502"><span class="hs-identifier hs-var">mb_demoted_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RnM (Maybe Name) -&gt; RnM (Maybe Name)
forall a. TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#discardErrs"><span class="hs-identifier hs-var">discardErrs</span></a></span><span> </span><span class="annot"><span class="annottext">(RnM (Maybe Name) -&gt; RnM (Maybe Name))
-&gt; RnM (Maybe Name) -&gt; RnM (Maybe Name)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-990"></span><span>                                         </span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupOccRn_maybe"><span class="hs-identifier hs-var">lookupOccRn_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107519"><span class="hs-identifier hs-var">demoted_rdr</span></a></span><span>
</span><span id="line-991"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107500"><span class="annot"><span class="annottext">suggestion :: MsgDoc
</span><a href="#local-6989586621681107500"><span class="hs-identifier hs-var hs-var">suggestion</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Maybe Name -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107502"><span class="hs-identifier hs-var">mb_demoted_name</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107498"><span class="hs-identifier hs-var">suggest_dk</span></a></span><span>
</span><span id="line-992"></span><span>                                     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107513"><span class="hs-identifier hs-var">star_info</span></a></span><span>
</span><span id="line-993"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WhereLooking -&gt; RdrName -&gt; MsgDoc -&gt; RnM Name
</span><a href="GHC.Rename.Unbound.html#unboundNameX"><span class="hs-identifier hs-var">unboundNameX</span></a></span><span> </span><span class="annot"><span class="annottext">WhereLooking
</span><a href="GHC.Rename.Unbound.html#WL_Any"><span class="hs-identifier hs-var">WL_Any</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107520"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107500"><span class="hs-identifier hs-var">suggestion</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-994"></span><span>
</span><span id="line-995"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-996"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Unbound.html#reportUnboundName"><span class="hs-identifier hs-var">reportUnboundName</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107520"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-997"></span><span>
</span><span id="line-998"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-999"></span><span>    </span><span id="local-6989586621681107498"><span class="annot"><span class="annottext">suggest_dk :: MsgDoc
</span><a href="#local-6989586621681107498"><span class="hs-identifier hs-var hs-var">suggest_dk</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;A data constructor of that name is in scope; did you mean DataKinds?&quot;</span></span><span>
</span><span id="line-1000"></span><span>    </span><span id="local-6989586621681107503"><span class="annot"><span class="annottext">untickedPromConstrWarn :: a -&gt; MsgDoc
</span><a href="#local-6989586621681107503"><span class="hs-identifier hs-var hs-var">untickedPromConstrWarn</span></a></span></span><span> </span><span id="local-6989586621681107493"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681107493"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1001"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unticked promoted constructor&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Utils.Outputable.html#colon"><span class="hs-identifier hs-var">colon</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681107493"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Utils.Outputable.html#dot"><span class="hs-identifier hs-var">dot</span></a></span><span>
</span><span id="line-1002"></span><span>      </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-1003"></span><span>      </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Use&quot;</span></span><span>
</span><span id="line-1004"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\''</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681107493"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1005"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;instead of&quot;</span></span><span>
</span><span id="line-1006"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681107493"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Utils.Outputable.html#dot"><span class="hs-identifier hs-var">dot</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1007"></span><span>
</span><span id="line-1008"></span><span class="annot"><a href="GHC.Rename.Env.html#badVarInType"><span class="hs-identifier hs-type">badVarInType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-1009"></span><span id="badVarInType"><span class="annot"><span class="annottext">badVarInType :: RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#badVarInType"><span class="hs-identifier hs-var hs-var">badVarInType</span></a></span></span><span> </span><span id="local-6989586621681107489"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107489"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-1010"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Illegal promoted term variable in a type:&quot;</span></span><span>
</span><span id="line-1011"></span><span>                 </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107489"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1012"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; Name
</span><a href="GHC.Rename.Unbound.html#mkUnboundNameRdr"><span class="hs-identifier hs-var">mkUnboundNameRdr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107489"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1013"></span><span>
</span><span id="line-1014"></span><span class="hs-comment">{- Note [Promoted variables in types]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this (#12686):
   x = True
   data Bad = Bad 'x

The parser treats the quote in 'x as saying &quot;use the term
namespace&quot;, so we'll get (Bad x{v}), with 'x' in the
VarName namespace.  If we don't test for this, the renamer
will happily rename it to the x bound at top level, and then
the typecheck falls over because it doesn't have 'x' in scope
when kind-checking.

Note [Demotion]
~~~~~~~~~~~~~~~
When the user writes:
  data Nat = Zero | Succ Nat
  foo :: f Zero -&gt; Int

'Zero' in the type signature of 'foo' is parsed as:
  HsTyVar (&quot;Zero&quot;, TcClsName)

When the renamer hits this occurrence of 'Zero' it's going to realise
that it's not in scope. But because it is renaming a type, it knows
that 'Zero' might be a promoted data constructor, so it will demote
its namespace to DataName and do a second lookup.

The final result (after the renamer) will be:
  HsTyVar (&quot;Zero&quot;, DataName)
-}</span><span>
</span><span id="line-1044"></span><span>
</span><span id="line-1045"></span><span id="local-6989586621681108315"><span class="annot"><a href="GHC.Rename.Env.html#lookupOccRnX_maybe"><span class="hs-identifier hs-type">lookupOccRnX_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681108315"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681108315"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span>
</span><span id="line-1046"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681108315"><span class="hs-identifier hs-type">r</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-1047"></span><span id="lookupOccRnX_maybe"><span class="annot"><span class="annottext">lookupOccRnX_maybe :: forall r.
(RdrName -&gt; RnM (Maybe r))
-&gt; (Name -&gt; r) -&gt; RdrName -&gt; RnM (Maybe r)
</span><a href="GHC.Rename.Env.html#lookupOccRnX_maybe"><span class="hs-identifier hs-var hs-var">lookupOccRnX_maybe</span></a></span></span><span> </span><span id="local-6989586621681107483"><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe r)
</span><a href="#local-6989586621681107483"><span class="hs-identifier hs-var">globalLookup</span></a></span></span><span> </span><span id="local-6989586621681107482"><span class="annot"><span class="annottext">Name -&gt; r
</span><a href="#local-6989586621681107482"><span class="hs-identifier hs-var">wrapper</span></a></span></span><span> </span><span id="local-6989586621681107481"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107481"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-1048"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r -&gt; RnM (Maybe r)
forall (m :: * -&gt; *) a. MaybeT m a -&gt; m (Maybe a)
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#runMaybeT"><span class="hs-identifier hs-var hs-var">runMaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r -&gt; RnM (Maybe r))
-&gt; ([RnM (Maybe r)] -&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r)
-&gt; [RnM (Maybe r)]
-&gt; RnM (Maybe r)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r]
-&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r
forall (t :: * -&gt; *) (m :: * -&gt; *) a.
(Foldable t, MonadPlus m) =&gt;
t (m a) -&gt; m a
</span><a href="../../base/src/Data.Foldable.html#msum"><span class="hs-identifier hs-var">msum</span></a></span><span> </span><span class="annot"><span class="annottext">([MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r]
 -&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r)
-&gt; ([RnM (Maybe r)] -&gt; [MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r])
-&gt; [RnM (Maybe r)]
-&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(RnM (Maybe r) -&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r)
-&gt; [RnM (Maybe r)] -&gt; [MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">RnM (Maybe r) -&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) r
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">([RnM (Maybe r)] -&gt; RnM (Maybe r))
-&gt; [RnM (Maybe r)] -&gt; RnM (Maybe r)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1049"></span><span>      </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; r) -&gt; Maybe Name -&gt; Maybe r
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; r
</span><a href="#local-6989586621681107482"><span class="hs-identifier hs-var">wrapper</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Name -&gt; Maybe r) -&gt; RnM (Maybe Name) -&gt; RnM (Maybe r)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupLocalOccRn_maybe"><span class="hs-identifier hs-var">lookupLocalOccRn_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107481"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1050"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe r)
</span><a href="#local-6989586621681107483"><span class="hs-identifier hs-var">globalLookup</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107481"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1051"></span><span>
</span><span id="line-1052"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupOccRn_maybe"><span class="hs-identifier hs-type">lookupOccRn_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1053"></span><span id="lookupOccRn_maybe"><span class="annot"><span class="annottext">lookupOccRn_maybe :: RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupOccRn_maybe"><span class="hs-identifier hs-var hs-var">lookupOccRn_maybe</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(RdrName -&gt; RnM (Maybe Name))
-&gt; (Name -&gt; Name) -&gt; RdrName -&gt; RnM (Maybe Name)
forall r.
(RdrName -&gt; RnM (Maybe r))
-&gt; (Name -&gt; r) -&gt; RdrName -&gt; RnM (Maybe r)
</span><a href="GHC.Rename.Env.html#lookupOccRnX_maybe"><span class="hs-identifier hs-var">lookupOccRnX_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupGlobalOccRn_maybe"><span class="hs-identifier hs-var">lookupGlobalOccRn_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1054"></span><span>
</span><span id="line-1055"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupOccRn_overloaded"><span class="hs-identifier hs-type">lookupOccRn_overloaded</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span>
</span><span id="line-1056"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1057"></span><span id="lookupOccRn_overloaded"><span class="annot"><span class="annottext">lookupOccRn_overloaded :: Bool -&gt; RdrName -&gt; RnM (Maybe (Either Name [Name]))
</span><a href="GHC.Rename.Env.html#lookupOccRn_overloaded"><span class="hs-identifier hs-var hs-var">lookupOccRn_overloaded</span></a></span></span><span> </span><span id="local-6989586621681107477"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107477"><span class="hs-identifier hs-var">overload_ok</span></a></span></span><span>
</span><span id="line-1058"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(RdrName -&gt; RnM (Maybe (Either Name [Name])))
-&gt; (Name -&gt; Either Name [Name])
-&gt; RdrName
-&gt; RnM (Maybe (Either Name [Name]))
forall r.
(RdrName -&gt; RnM (Maybe r))
-&gt; (Name -&gt; r) -&gt; RdrName -&gt; RnM (Maybe r)
</span><a href="GHC.Rename.Env.html#lookupOccRnX_maybe"><span class="hs-identifier hs-var">lookupOccRnX_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe (Either Name [Name]))
</span><a href="#local-6989586621681107476"><span class="hs-identifier hs-var">global_lookup</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Either Name [Name]
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span>
</span><span id="line-1059"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1060"></span><span>        </span><span class="annot"><a href="#local-6989586621681107476"><span class="hs-identifier hs-type">global_lookup</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1061"></span><span>        </span><span id="local-6989586621681107476"><span class="annot"><span class="annottext">global_lookup :: RdrName -&gt; RnM (Maybe (Either Name [Name]))
</span><a href="#local-6989586621681107476"><span class="hs-identifier hs-var hs-var">global_lookup</span></a></span></span><span> </span><span id="local-6989586621681107475"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107475"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1062"></span><span>          </span><span class="annot"><span class="annottext">MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name])
-&gt; RnM (Maybe (Either Name [Name]))
forall (m :: * -&gt; *) a. MaybeT m a -&gt; m (Maybe a)
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#runMaybeT"><span class="hs-identifier hs-var hs-var">runMaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name])
 -&gt; RnM (Maybe (Either Name [Name])))
-&gt; ([RnM (Maybe (Either Name [Name]))]
    -&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name]))
-&gt; [RnM (Maybe (Either Name [Name]))]
-&gt; RnM (Maybe (Either Name [Name]))
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name])]
-&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name])
forall (t :: * -&gt; *) (m :: * -&gt; *) a.
(Foldable t, MonadPlus m) =&gt;
t (m a) -&gt; m a
</span><a href="../../base/src/Data.Foldable.html#msum"><span class="hs-identifier hs-var">msum</span></a></span><span> </span><span class="annot"><span class="annottext">([MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name])]
 -&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name]))
-&gt; ([RnM (Maybe (Either Name [Name]))]
    -&gt; [MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name])])
-&gt; [RnM (Maybe (Either Name [Name]))]
-&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name])
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(RnM (Maybe (Either Name [Name]))
 -&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name]))
-&gt; [RnM (Maybe (Either Name [Name]))]
-&gt; [MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name])]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">RnM (Maybe (Either Name [Name]))
-&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) (Either Name [Name])
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">([RnM (Maybe (Either Name [Name]))]
 -&gt; RnM (Maybe (Either Name [Name])))
-&gt; [RnM (Maybe (Either Name [Name]))]
-&gt; RnM (Maybe (Either Name [Name]))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1063"></span><span>            </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; RdrName -&gt; RnM (Maybe (Either Name [Name]))
</span><a href="GHC.Rename.Env.html#lookupGlobalOccRn_overloaded"><span class="hs-identifier hs-var">lookupGlobalOccRn_overloaded</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107477"><span class="hs-identifier hs-var">overload_ok</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107475"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1064"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Either Name [Name])
-&gt; Maybe Name -&gt; Maybe (Either Name [Name])
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Either Name [Name]
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Name -&gt; Maybe (Either Name [Name]))
-&gt; ([Name] -&gt; Maybe Name) -&gt; [Name] -&gt; Maybe (Either Name [Name])
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; Maybe Name
forall a. [a] -&gt; Maybe a
</span><a href="../../base/src/Data.Maybe.html#listToMaybe"><span class="hs-identifier hs-var">listToMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">([Name] -&gt; Maybe (Either Name [Name]))
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
-&gt; RnM (Maybe (Either Name [Name]))
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
</span><a href="GHC.Rename.Env.html#lookupQualifiedNameGHCi"><span class="hs-identifier hs-var">lookupQualifiedNameGHCi</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107475"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1065"></span><span>
</span><span id="line-1066"></span><span>
</span><span id="line-1067"></span><span>
</span><span id="line-1068"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupGlobalOccRn_maybe"><span class="hs-identifier hs-type">lookupGlobalOccRn_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1069"></span><span class="hs-comment">-- Looks up a RdrName occurrence in the top-level</span><span>
</span><span id="line-1070"></span><span class="hs-comment">-- environment, including using lookupQualifiedNameGHCi</span><span>
</span><span id="line-1071"></span><span class="hs-comment">-- for the GHCi case, but first tries to find an Exact or Orig name.</span><span>
</span><span id="line-1072"></span><span class="hs-comment">-- No filter function; does not report an error on failure</span><span>
</span><span id="line-1073"></span><span class="hs-comment">-- See Note [Errors in lookup functions]</span><span>
</span><span id="line-1074"></span><span class="hs-comment">-- Uses addUsedRdrName to record use and deprecations</span><span>
</span><span id="line-1075"></span><span id="lookupGlobalOccRn_maybe"><span class="annot"><span class="annottext">lookupGlobalOccRn_maybe :: RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupGlobalOccRn_maybe"><span class="hs-identifier hs-var hs-var">lookupGlobalOccRn_maybe</span></a></span></span><span> </span><span id="local-6989586621681107472"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107472"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1076"></span><span>  </span><span class="annot"><span class="annottext">RdrName
-&gt; (Maybe Name -&gt; Maybe Name)
-&gt; RnM (Maybe Name)
-&gt; RnM (Maybe Name)
forall r. RdrName -&gt; (Maybe Name -&gt; r) -&gt; RnM r -&gt; RnM r
</span><a href="GHC.Rename.Env.html#lookupExactOrOrig_maybe"><span class="hs-identifier hs-var">lookupExactOrOrig_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107472"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Name -&gt; Maybe Name
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupGlobalOccRn_base"><span class="hs-identifier hs-var">lookupGlobalOccRn_base</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107472"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1077"></span><span>
</span><span id="line-1078"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupGlobalOccRn"><span class="hs-identifier hs-type">lookupGlobalOccRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-1079"></span><span class="hs-comment">-- lookupGlobalOccRn is like lookupOccRn, except that it looks in the global</span><span>
</span><span id="line-1080"></span><span class="hs-comment">-- environment.  Adds an error message if the RdrName is not in scope.</span><span>
</span><span id="line-1081"></span><span class="hs-comment">-- You usually want to use &quot;lookupOccRn&quot; which also looks in the local</span><span>
</span><span id="line-1082"></span><span class="hs-comment">-- environment.</span><span>
</span><span id="line-1083"></span><span id="lookupGlobalOccRn"><span class="annot"><span class="annottext">lookupGlobalOccRn :: RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupGlobalOccRn"><span class="hs-identifier hs-var hs-var">lookupGlobalOccRn</span></a></span></span><span> </span><span id="local-6989586621681107470"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107470"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1084"></span><span>  </span><span class="annot"><span class="annottext">RdrName -&gt; (Name -&gt; Name) -&gt; RnM Name -&gt; RnM Name
forall r. RdrName -&gt; (Name -&gt; r) -&gt; RnM r -&gt; RnM r
</span><a href="GHC.Rename.Env.html#lookupExactOrOrig"><span class="hs-identifier hs-var">lookupExactOrOrig</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107470"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">(RnM Name -&gt; RnM Name) -&gt; RnM Name -&gt; RnM Name
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1085"></span><span>    </span><span id="local-6989586621681107469"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107469"><span class="hs-identifier hs-var">mn</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupGlobalOccRn_base"><span class="hs-identifier hs-var">lookupGlobalOccRn_base</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107470"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1086"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107469"><span class="hs-identifier hs-var">mn</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1087"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107468"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107468"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107468"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1088"></span><span>      </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupGlobalOccRn&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107470"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1089"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WhereLooking -&gt; RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Unbound.html#unboundName"><span class="hs-identifier hs-var">unboundName</span></a></span><span> </span><span class="annot"><span class="annottext">WhereLooking
</span><a href="GHC.Rename.Unbound.html#WL_Global"><span class="hs-identifier hs-var">WL_Global</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107470"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1090"></span><span>
</span><span id="line-1091"></span><span class="hs-comment">-- Looks up a RdrName occurence in the GlobalRdrEnv and with</span><span>
</span><span id="line-1092"></span><span class="hs-comment">-- lookupQualifiedNameGHCi. Does not try to find an Exact or Orig name first.</span><span>
</span><span id="line-1093"></span><span class="hs-comment">-- lookupQualifiedNameGHCi here is used when we're in GHCi and a name like</span><span>
</span><span id="line-1094"></span><span class="hs-comment">-- 'Data.Map.elems' is typed, even if you didn't import Data.Map</span><span>
</span><span id="line-1095"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupGlobalOccRn_base"><span class="hs-identifier hs-type">lookupGlobalOccRn_base</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1096"></span><span id="lookupGlobalOccRn_base"><span class="annot"><span class="annottext">lookupGlobalOccRn_base :: RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupGlobalOccRn_base"><span class="hs-identifier hs-var hs-var">lookupGlobalOccRn_base</span></a></span></span><span> </span><span id="local-6989586621681107466"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107466"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1097"></span><span>  </span><span class="annot"><span class="annottext">MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name -&gt; RnM (Maybe Name)
forall (m :: * -&gt; *) a. MaybeT m a -&gt; m (Maybe a)
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#runMaybeT"><span class="hs-identifier hs-var hs-var">runMaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">(MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name -&gt; RnM (Maybe Name))
-&gt; ([RnM (Maybe Name)]
    -&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name)
-&gt; [RnM (Maybe Name)]
-&gt; RnM (Maybe Name)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name]
-&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name
forall (t :: * -&gt; *) (m :: * -&gt; *) a.
(Foldable t, MonadPlus m) =&gt;
t (m a) -&gt; m a
</span><a href="../../base/src/Data.Foldable.html#msum"><span class="hs-identifier hs-var">msum</span></a></span><span> </span><span class="annot"><span class="annottext">([MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name]
 -&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name)
-&gt; ([RnM (Maybe Name)]
    -&gt; [MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name])
-&gt; [RnM (Maybe Name)]
-&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(RnM (Maybe Name) -&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name)
-&gt; [RnM (Maybe Name)]
-&gt; [MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">RnM (Maybe Name) -&gt; MaybeT (IOEnv (Env TcGblEnv TcLclEnv)) Name
forall (m :: * -&gt; *) a. m (Maybe a) -&gt; MaybeT m a
</span><a href="../../transformers/src/Control.Monad.Trans.Maybe.html#MaybeT"><span class="hs-identifier hs-var">MaybeT</span></a></span><span> </span><span class="annot"><span class="annottext">([RnM (Maybe Name)] -&gt; RnM (Maybe Name))
-&gt; [RnM (Maybe Name)] -&gt; RnM (Maybe Name)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1098"></span><span>    </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Name) -&gt; Maybe GlobalRdrElt -&gt; Maybe Name
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe GlobalRdrElt -&gt; Maybe Name)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe GlobalRdrElt)
-&gt; RnM (Maybe Name)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe GlobalRdrElt)
</span><a href="GHC.Rename.Env.html#lookupGreRn_maybe"><span class="hs-identifier hs-var">lookupGreRn_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107466"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1099"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; Maybe Name
forall a. [a] -&gt; Maybe a
</span><a href="../../base/src/Data.Maybe.html#listToMaybe"><span class="hs-identifier hs-var">listToMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">([Name] -&gt; Maybe Name)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name] -&gt; RnM (Maybe Name)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
</span><a href="GHC.Rename.Env.html#lookupQualifiedNameGHCi"><span class="hs-identifier hs-var">lookupQualifiedNameGHCi</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107466"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1100"></span><span>                      </span><span class="hs-comment">-- This test is not expensive,</span><span>
</span><span id="line-1101"></span><span>                      </span><span class="hs-comment">-- and only happens for failed lookups</span><span>
</span><span id="line-1102"></span><span>
</span><span id="line-1103"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupInfoOccRn"><span class="hs-identifier hs-type">lookupInfoOccRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1104"></span><span class="hs-comment">-- lookupInfoOccRn is intended for use in GHCi's &quot;:info&quot; command</span><span>
</span><span id="line-1105"></span><span class="hs-comment">-- It finds all the GREs that RdrName could mean, not complaining</span><span>
</span><span id="line-1106"></span><span class="hs-comment">-- about ambiguity, but rather returning them all</span><span>
</span><span id="line-1107"></span><span class="hs-comment">-- C.f. #9881</span><span>
</span><span id="line-1108"></span><span class="hs-comment">-- lookupInfoOccRn is also used in situations where we check for</span><span>
</span><span id="line-1109"></span><span class="hs-comment">-- at least one definition of the RdrName, not complaining about</span><span>
</span><span id="line-1110"></span><span class="hs-comment">-- multiple definitions. (See #17832)</span><span>
</span><span id="line-1111"></span><span id="lookupInfoOccRn"><span class="annot"><span class="annottext">lookupInfoOccRn :: RdrName -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
</span><a href="GHC.Rename.Env.html#lookupInfoOccRn"><span class="hs-identifier hs-var hs-var">lookupInfoOccRn</span></a></span></span><span> </span><span id="local-6989586621681107464"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107464"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1112"></span><span>  </span><span class="annot"><span class="annottext">RdrName
-&gt; (Name -&gt; [Name])
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
forall r. RdrName -&gt; (Name -&gt; r) -&gt; RnM r -&gt; RnM r
</span><a href="GHC.Rename.Env.html#lookupExactOrOrig"><span class="hs-identifier hs-var">lookupExactOrOrig</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107464"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; [Name] -&gt; [Name]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOEnv (Env TcGblEnv TcLclEnv) [Name]
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name])
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1113"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107463"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107463"><span class="hs-identifier hs-var">rdr_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn GlobalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getGlobalRdrEnv"><span class="hs-identifier hs-var">getGlobalRdrEnv</span></a></span><span>
</span><span id="line-1114"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107462"><span class="annot"><span class="annottext">ns :: [Name]
</span><a href="#local-6989586621681107462"><span class="hs-identifier hs-var hs-var">ns</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Name) -&gt; [GlobalRdrElt] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; GlobalRdrEnv -&gt; [GlobalRdrElt]
</span><a href="GHC.Types.Name.Reader.html#lookupGRE_RdrName"><span class="hs-identifier hs-var">lookupGRE_RdrName</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107464"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107463"><span class="hs-identifier hs-var">rdr_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1115"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681107461"><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107461"><span class="hs-identifier hs-var">qual_ns</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
</span><a href="GHC.Rename.Env.html#lookupQualifiedNameGHCi"><span class="hs-identifier hs-var">lookupQualifiedNameGHCi</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107464"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1116"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107462"><span class="hs-identifier hs-var">ns</span></a></span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; [Name] -&gt; [Name]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107461"><span class="hs-identifier hs-var">qual_ns</span></a></span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; [Name] -&gt; [Name]
forall a. Ord a =&gt; [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Data.List.SetOps.html#minusList"><span class="hs-operator hs-var">`minusList`</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107462"><span class="hs-identifier hs-var">ns</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1117"></span><span>
</span><span id="line-1118"></span><span class="hs-comment">-- | Like 'lookupOccRn_maybe', but with a more informative result if</span><span>
</span><span id="line-1119"></span><span class="hs-comment">-- the 'RdrName' happens to be a record selector:</span><span>
</span><span id="line-1120"></span><span class="hs-comment">--</span><span>
</span><span id="line-1121"></span><span class="hs-comment">--   * Nothing         -&gt; name not in scope (no error reported)</span><span>
</span><span id="line-1122"></span><span class="hs-comment">--   * Just (Left x)   -&gt; name uniquely refers to x,</span><span>
</span><span id="line-1123"></span><span class="hs-comment">--                        or there is a name clash (reported)</span><span>
</span><span id="line-1124"></span><span class="hs-comment">--   * Just (Right xs) -&gt; name refers to one or more record selectors;</span><span>
</span><span id="line-1125"></span><span class="hs-comment">--                        if overload_ok was False, this list will be</span><span>
</span><span id="line-1126"></span><span class="hs-comment">--                        a singleton.</span><span>
</span><span id="line-1127"></span><span>
</span><span id="line-1128"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupGlobalOccRn_overloaded"><span class="hs-identifier hs-type">lookupGlobalOccRn_overloaded</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span>
</span><span id="line-1129"></span><span>                             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1130"></span><span id="lookupGlobalOccRn_overloaded"><span class="annot"><span class="annottext">lookupGlobalOccRn_overloaded :: Bool -&gt; RdrName -&gt; RnM (Maybe (Either Name [Name]))
</span><a href="GHC.Rename.Env.html#lookupGlobalOccRn_overloaded"><span class="hs-identifier hs-var hs-var">lookupGlobalOccRn_overloaded</span></a></span></span><span> </span><span id="local-6989586621681107460"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107460"><span class="hs-identifier hs-var">overload_ok</span></a></span></span><span> </span><span id="local-6989586621681107459"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107459"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1131"></span><span>  </span><span class="annot"><span class="annottext">RdrName
-&gt; (Maybe Name -&gt; Maybe (Either Name [Name]))
-&gt; RnM (Maybe (Either Name [Name]))
-&gt; RnM (Maybe (Either Name [Name]))
forall r. RdrName -&gt; (Maybe Name -&gt; r) -&gt; RnM r -&gt; RnM r
</span><a href="GHC.Rename.Env.html#lookupExactOrOrig_maybe"><span class="hs-identifier hs-var">lookupExactOrOrig_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107459"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Name -&gt; Either Name [Name])
-&gt; Maybe Name -&gt; Maybe (Either Name [Name])
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Either Name [Name]
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(RnM (Maybe (Either Name [Name]))
 -&gt; RnM (Maybe (Either Name [Name])))
-&gt; RnM (Maybe (Either Name [Name]))
-&gt; RnM (Maybe (Either Name [Name]))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1132"></span><span>     </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107458"><span class="annot"><span class="annottext">GreLookupResult
</span><a href="#local-6989586621681107458"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM GreLookupResult
</span><a href="GHC.Rename.Env.html#lookupGreRn_helper"><span class="hs-identifier hs-var">lookupGreRn_helper</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107459"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1133"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">GreLookupResult
</span><a href="#local-6989586621681107458"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1134"></span><span>                </span><span class="annot"><span class="annottext">GreLookupResult
</span><a href="GHC.Rename.Env.html#GreNotFound"><span class="hs-identifier hs-var">GreNotFound</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe (Either Name [Name]) -&gt; RnM (Maybe (Either Name [Name]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Either Name [Name])
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1135"></span><span>                </span><span class="annot"><a href="GHC.Rename.Env.html#OneNameMatch"><span class="hs-identifier hs-type">OneNameMatch</span></a></span><span> </span><span id="local-6989586621681107454"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107454"><span class="hs-identifier hs-var">gre</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1136"></span><span>                  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107453"><span class="annot"><span class="annottext">wrapper :: a -&gt; Either a [a]
</span><a href="#local-6989586621681107453"><span class="hs-identifier hs-var hs-var">wrapper</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#isRecFldGRE"><span class="hs-identifier hs-var">isRecFldGRE</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107454"><span class="hs-identifier hs-var">gre</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Either a [a]
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">([a] -&gt; Either a [a]) -&gt; (a -&gt; [a]) -&gt; a -&gt; Either a [a]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">a -&gt; Either a [a]
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span>
</span><span id="line-1137"></span><span>                  </span><span class="annot"><span class="annottext">Maybe (Either Name [Name]) -&gt; RnM (Maybe (Either Name [Name]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe (Either Name [Name]) -&gt; RnM (Maybe (Either Name [Name])))
-&gt; Maybe (Either Name [Name]) -&gt; RnM (Maybe (Either Name [Name]))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Either Name [Name] -&gt; Maybe (Either Name [Name])
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either Name [Name]
forall {a}. a -&gt; Either a [a]
</span><a href="#local-6989586621681107453"><span class="hs-identifier hs-var">wrapper</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107454"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1138"></span><span>                </span><span class="annot"><a href="GHC.Rename.Env.html#MultipleNames"><span class="hs-identifier hs-type">MultipleNames</span></a></span><span> </span><span id="local-6989586621681107451"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107451"><span class="hs-identifier hs-var">gres</span></a></span></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Bool) -&gt; [GlobalRdrElt] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#isRecFldGRE"><span class="hs-identifier hs-var">isRecFldGRE</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107451"><span class="hs-identifier hs-var">gres</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107460"><span class="hs-identifier hs-var">overload_ok</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1139"></span><span>                  </span><span class="hs-comment">-- Don't record usage for ambiguous selectors</span><span>
</span><span id="line-1140"></span><span>                  </span><span class="hs-comment">-- until we know which is meant</span><span>
</span><span id="line-1141"></span><span>                  </span><span class="annot"><span class="annottext">Maybe (Either Name [Name]) -&gt; RnM (Maybe (Either Name [Name]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe (Either Name [Name]) -&gt; RnM (Maybe (Either Name [Name])))
-&gt; Maybe (Either Name [Name]) -&gt; RnM (Maybe (Either Name [Name]))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Either Name [Name] -&gt; Maybe (Either Name [Name])
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Name] -&gt; Either Name [Name]
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Name) -&gt; [GlobalRdrElt] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107451"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1142"></span><span>                </span><span class="annot"><a href="GHC.Rename.Env.html#MultipleNames"><span class="hs-identifier hs-type">MultipleNames</span></a></span><span> </span><span id="local-6989586621681107450"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107450"><span class="hs-identifier hs-var">gres</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1143"></span><span>                  </span><span class="annot"><span class="annottext">RdrName -&gt; [GlobalRdrElt] -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Utils.html#addNameClashErrRn"><span class="hs-identifier hs-var">addNameClashErrRn</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107459"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107450"><span class="hs-identifier hs-var">gres</span></a></span><span>
</span><span id="line-1144"></span><span>                  </span><span class="annot"><span class="annottext">Maybe (Either Name [Name]) -&gt; RnM (Maybe (Either Name [Name]))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Either Name [Name] -&gt; Maybe (Either Name [Name])
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either Name [Name]
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; GlobalRdrElt
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107450"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1145"></span><span>
</span><span id="line-1146"></span><span>
</span><span id="line-1147"></span><span class="hs-comment">--------------------------------------------------</span><span>
</span><span id="line-1148"></span><span class="hs-comment">--      Lookup in the Global RdrEnv of the module</span><span>
</span><span id="line-1149"></span><span class="hs-comment">--------------------------------------------------</span><span>
</span><span id="line-1150"></span><span>
</span><span id="line-1151"></span><span class="hs-keyword">data</span><span> </span><span id="GreLookupResult"><span class="annot"><a href="GHC.Rename.Env.html#GreLookupResult"><span class="hs-identifier hs-var">GreLookupResult</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="GreNotFound"><span class="annot"><a href="GHC.Rename.Env.html#GreNotFound"><span class="hs-identifier hs-var">GreNotFound</span></a></span></span><span>
</span><span id="line-1152"></span><span>                     </span><span class="hs-glyph">|</span><span> </span><span id="OneNameMatch"><span class="annot"><a href="GHC.Rename.Env.html#OneNameMatch"><span class="hs-identifier hs-var">OneNameMatch</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span>
</span><span id="line-1153"></span><span>                     </span><span class="hs-glyph">|</span><span> </span><span id="MultipleNames"><span class="annot"><a href="GHC.Rename.Env.html#MultipleNames"><span class="hs-identifier hs-var">MultipleNames</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1154"></span><span>
</span><span id="line-1155"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupGreRn_maybe"><span class="hs-identifier hs-type">lookupGreRn_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1156"></span><span class="hs-comment">-- Look up the RdrName in the GlobalRdrEnv</span><span>
</span><span id="line-1157"></span><span class="hs-comment">--   Exactly one binding: records it as &quot;used&quot;, return (Just gre)</span><span>
</span><span id="line-1158"></span><span class="hs-comment">--   No bindings:         return Nothing</span><span>
</span><span id="line-1159"></span><span class="hs-comment">--   Many bindings:       report &quot;ambiguous&quot;, return an arbitrary (Just gre)</span><span>
</span><span id="line-1160"></span><span class="hs-comment">-- Uses addUsedRdrName to record use and deprecations</span><span>
</span><span id="line-1161"></span><span id="lookupGreRn_maybe"><span class="annot"><span class="annottext">lookupGreRn_maybe :: RdrName -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe GlobalRdrElt)
</span><a href="GHC.Rename.Env.html#lookupGreRn_maybe"><span class="hs-identifier hs-var hs-var">lookupGreRn_maybe</span></a></span></span><span> </span><span id="local-6989586621681107449"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107449"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-1162"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1163"></span><span>      </span><span id="local-6989586621681107448"><span class="annot"><span class="annottext">GreLookupResult
</span><a href="#local-6989586621681107448"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM GreLookupResult
</span><a href="GHC.Rename.Env.html#lookupGreRn_helper"><span class="hs-identifier hs-var">lookupGreRn_helper</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107449"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1164"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">GreLookupResult
</span><a href="#local-6989586621681107448"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1165"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#OneNameMatch"><span class="hs-identifier hs-type">OneNameMatch</span></a></span><span> </span><span id="local-6989586621681107447"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107447"><span class="hs-identifier hs-var">gre</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>  </span><span class="annot"><span class="annottext">Maybe GlobalRdrElt
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe GlobalRdrElt
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe GlobalRdrElt))
-&gt; Maybe GlobalRdrElt
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe GlobalRdrElt)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Maybe GlobalRdrElt
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107447"><span class="hs-identifier hs-var">gre</span></a></span><span>
</span><span id="line-1166"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#MultipleNames"><span class="hs-identifier hs-type">MultipleNames</span></a></span><span> </span><span id="local-6989586621681107446"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107446"><span class="hs-identifier hs-var">gres</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1167"></span><span>          </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupGreRn_maybe:NameClash&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107446"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1168"></span><span>          </span><span class="annot"><span class="annottext">RdrName -&gt; [GlobalRdrElt] -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Utils.html#addNameClashErrRn"><span class="hs-identifier hs-var">addNameClashErrRn</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107449"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107446"><span class="hs-identifier hs-var">gres</span></a></span><span>
</span><span id="line-1169"></span><span>          </span><span class="annot"><span class="annottext">Maybe GlobalRdrElt
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe GlobalRdrElt
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe GlobalRdrElt))
-&gt; Maybe GlobalRdrElt
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe GlobalRdrElt)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Maybe GlobalRdrElt
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; GlobalRdrElt
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107446"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1170"></span><span>        </span><span class="annot"><span class="annottext">GreLookupResult
</span><a href="GHC.Rename.Env.html#GreNotFound"><span class="hs-identifier hs-var">GreNotFound</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe GlobalRdrElt
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe GlobalRdrElt
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1171"></span><span>
</span><span id="line-1172"></span><span class="hs-comment">{-

Note [ Unbound vs Ambiguous Names ]

lookupGreRn_maybe deals with failures in two different ways. If a name
is unbound then we return a `Nothing` but if the name is ambiguous
then we raise an error and return a dummy name.

The reason for this is that when we call `lookupGreRn_maybe` we are
speculatively looking for whatever we are looking up. If we don't find it,
then we might have been looking for the wrong thing and can keep trying.
On the other hand, if we find a clash then there is no way to recover as
we found the thing we were looking for but can no longer resolve which
the correct one is.

One example of this is in `lookupTypeOccRn` which first looks in the type
constructor namespace before looking in the data constructor namespace to
deal with `DataKinds`.

There is however, as always, one exception to this scheme. If we find
an ambiguous occurrence of a record selector and DuplicateRecordFields
is enabled then we defer the selection until the typechecker.

-}</span><span>
</span><span id="line-1196"></span><span>
</span><span id="line-1197"></span><span>
</span><span id="line-1198"></span><span>
</span><span id="line-1199"></span><span>
</span><span id="line-1200"></span><span class="hs-comment">-- Internal Function</span><span>
</span><span id="line-1201"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupGreRn_helper"><span class="hs-identifier hs-type">lookupGreRn_helper</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#GreLookupResult"><span class="hs-identifier hs-type">GreLookupResult</span></a></span><span>
</span><span id="line-1202"></span><span id="lookupGreRn_helper"><span class="annot"><span class="annottext">lookupGreRn_helper :: RdrName -&gt; RnM GreLookupResult
</span><a href="GHC.Rename.Env.html#lookupGreRn_helper"><span class="hs-identifier hs-var hs-var">lookupGreRn_helper</span></a></span></span><span> </span><span id="local-6989586621681107445"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107445"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-1203"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107444"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107444"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn GlobalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getGlobalRdrEnv"><span class="hs-identifier hs-var">getGlobalRdrEnv</span></a></span><span>
</span><span id="line-1204"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; GlobalRdrEnv -&gt; [GlobalRdrElt]
</span><a href="GHC.Types.Name.Reader.html#lookupGRE_RdrName"><span class="hs-identifier hs-var">lookupGRE_RdrName</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107445"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107444"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1205"></span><span>            </span><span class="hs-special">[</span><span class="hs-special">]</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">GreLookupResult -&gt; RnM GreLookupResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">GreLookupResult
</span><a href="GHC.Rename.Env.html#GreNotFound"><span class="hs-identifier hs-var">GreNotFound</span></a></span><span>
</span><span id="line-1206"></span><span>            </span><span class="hs-special">[</span><span id="local-6989586621681107443"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107443"><span class="hs-identifier hs-var">gre</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; GlobalRdrElt -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Env.html#addUsedGRE"><span class="hs-identifier hs-var">addUsedGRE</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107443"><span class="hs-identifier hs-var">gre</span></a></span><span>
</span><span id="line-1207"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">GreLookupResult -&gt; RnM GreLookupResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; GreLookupResult
</span><a href="GHC.Rename.Env.html#OneNameMatch"><span class="hs-identifier hs-var">OneNameMatch</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107443"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1208"></span><span>            </span><span id="local-6989586621681107442"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107442"><span class="hs-identifier hs-var">gres</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">GreLookupResult -&gt; RnM GreLookupResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; GreLookupResult
</span><a href="GHC.Rename.Env.html#MultipleNames"><span class="hs-identifier hs-var">MultipleNames</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107442"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1209"></span><span>
</span><span id="line-1210"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupGreAvailRn"><span class="hs-identifier hs-type">lookupGreAvailRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Avail.html#AvailInfo"><span class="hs-identifier hs-type">AvailInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1211"></span><span class="hs-comment">-- Used in export lists</span><span>
</span><span id="line-1212"></span><span class="hs-comment">-- If not found or ambiguous, add error message, and fake with UnboundName</span><span>
</span><span id="line-1213"></span><span class="hs-comment">-- Uses addUsedRdrName to record use and deprecations</span><span>
</span><span id="line-1214"></span><span id="lookupGreAvailRn"><span class="annot"><span class="annottext">lookupGreAvailRn :: RdrName -&gt; RnM (Name, AvailInfo)
</span><a href="GHC.Rename.Env.html#lookupGreAvailRn"><span class="hs-identifier hs-var hs-var">lookupGreAvailRn</span></a></span></span><span> </span><span id="local-6989586621681107441"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107441"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-1215"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1216"></span><span>      </span><span id="local-6989586621681107440"><span class="annot"><span class="annottext">GreLookupResult
</span><a href="#local-6989586621681107440"><span class="hs-identifier hs-var">mb_gre</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM GreLookupResult
</span><a href="GHC.Rename.Env.html#lookupGreRn_helper"><span class="hs-identifier hs-var">lookupGreRn_helper</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107441"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1217"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">GreLookupResult
</span><a href="#local-6989586621681107440"><span class="hs-identifier hs-var">mb_gre</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1218"></span><span>        </span><span class="annot"><span class="annottext">GreLookupResult
</span><a href="GHC.Rename.Env.html#GreNotFound"><span class="hs-identifier hs-var">GreNotFound</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1219"></span><span>          </span><span class="hs-keyword">do</span><span>
</span><span id="line-1220"></span><span>            </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupGreAvailRn&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107441"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1221"></span><span>            </span><span id="local-6989586621681107439"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107439"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WhereLooking -&gt; RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Unbound.html#unboundName"><span class="hs-identifier hs-var">unboundName</span></a></span><span> </span><span class="annot"><span class="annottext">WhereLooking
</span><a href="GHC.Rename.Unbound.html#WL_Global"><span class="hs-identifier hs-var">WL_Global</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107441"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1222"></span><span>            </span><span class="annot"><span class="annottext">(Name, AvailInfo) -&gt; RnM (Name, AvailInfo)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107439"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; AvailInfo
</span><a href="GHC.Types.Avail.html#avail"><span class="hs-identifier hs-var">avail</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107439"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1223"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#MultipleNames"><span class="hs-identifier hs-type">MultipleNames</span></a></span><span> </span><span id="local-6989586621681107437"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107437"><span class="hs-identifier hs-var">gres</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1224"></span><span>          </span><span class="hs-keyword">do</span><span>
</span><span id="line-1225"></span><span>            </span><span class="annot"><span class="annottext">RdrName -&gt; [GlobalRdrElt] -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Utils.html#addNameClashErrRn"><span class="hs-identifier hs-var">addNameClashErrRn</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107441"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107437"><span class="hs-identifier hs-var">gres</span></a></span><span>
</span><span id="line-1226"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107436"><span class="annot"><span class="annottext">unbound_name :: Name
</span><a href="#local-6989586621681107436"><span class="hs-identifier hs-var hs-var">unbound_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; Name
</span><a href="GHC.Rename.Unbound.html#mkUnboundNameRdr"><span class="hs-identifier hs-var">mkUnboundNameRdr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107441"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1227"></span><span>            </span><span class="annot"><span class="annottext">(Name, AvailInfo) -&gt; RnM (Name, AvailInfo)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107436"><span class="hs-identifier hs-var">unbound_name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; AvailInfo
</span><a href="GHC.Types.Avail.html#avail"><span class="hs-identifier hs-var">avail</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107436"><span class="hs-identifier hs-var">unbound_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1228"></span><span>                        </span><span class="hs-comment">-- Returning an unbound name here prevents an error</span><span>
</span><span id="line-1229"></span><span>                        </span><span class="hs-comment">-- cascade</span><span>
</span><span id="line-1230"></span><span>        </span><span class="annot"><a href="GHC.Rename.Env.html#OneNameMatch"><span class="hs-identifier hs-type">OneNameMatch</span></a></span><span> </span><span id="local-6989586621681107435"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107435"><span class="hs-identifier hs-var">gre</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1231"></span><span>          </span><span class="annot"><span class="annottext">(Name, AvailInfo) -&gt; RnM (Name, AvailInfo)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107435"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; AvailInfo
</span><a href="GHC.Types.Name.Reader.html#availFromGRE"><span class="hs-identifier hs-var">availFromGRE</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107435"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1232"></span><span>
</span><span id="line-1233"></span><span>
</span><span id="line-1234"></span><span class="hs-comment">{-
*********************************************************
*                                                      *
                Deprecations
*                                                      *
*********************************************************

Note [Handling of deprecations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* We report deprecations at each *occurrence* of the deprecated thing
  (see #5867)

* We do not report deprecations for locally-defined names. For a
  start, we may be exporting a deprecated thing. Also we may use a
  deprecated thing in the defn of another deprecated things.  We may
  even use a deprecated thing in the defn of a non-deprecated thing,
  when changing a module's interface.

* addUsedGREs: we do not report deprecations for sub-binders:
     - the &quot;..&quot; completion for records
     - the &quot;..&quot; in an export item 'T(..)'
     - the things exported by a module export 'module M'
-}</span><span>
</span><span id="line-1257"></span><span>
</span><span id="line-1258"></span><span class="annot"><a href="GHC.Rename.Env.html#addUsedDataCons"><span class="hs-identifier hs-type">addUsedDataCons</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrEnv"><span class="hs-identifier hs-type">GlobalRdrEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1259"></span><span class="hs-comment">-- Remember use of in-scope data constructors (#7969)</span><span>
</span><span id="line-1260"></span><span id="addUsedDataCons"><span class="annot"><span class="annottext">addUsedDataCons :: GlobalRdrEnv -&gt; TyCon -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Env.html#addUsedDataCons"><span class="hs-identifier hs-var hs-var">addUsedDataCons</span></a></span></span><span> </span><span id="local-6989586621681107433"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107433"><span class="hs-identifier hs-var">rdr_env</span></a></span></span><span> </span><span id="local-6989586621681107432"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681107432"><span class="hs-identifier hs-var">tycon</span></a></span></span><span>
</span><span id="line-1261"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Env.html#addUsedGREs"><span class="hs-identifier hs-var">addUsedGREs</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107431"><span class="hs-identifier hs-var">gre</span></a></span><span>
</span><span id="line-1262"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681107430"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681107430"><span class="hs-identifier hs-var">dc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons"><span class="hs-identifier hs-var">tyConDataCons</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681107432"><span class="hs-identifier hs-var">tycon</span></a></span><span>
</span><span id="line-1263"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107431"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107431"><span class="hs-identifier hs-var">gre</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">GlobalRdrEnv -&gt; Name -&gt; Maybe GlobalRdrElt
</span><a href="GHC.Types.Name.Reader.html#lookupGRE_Name"><span class="hs-identifier hs-var">lookupGRE_Name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107433"><span class="hs-identifier hs-var">rdr_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; Name
</span><a href="GHC.Core.DataCon.html#dataConName"><span class="hs-identifier hs-var">dataConName</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681107430"><span class="hs-identifier hs-var">dc</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1264"></span><span>
</span><span id="line-1265"></span><span class="annot"><a href="GHC.Rename.Env.html#addUsedGRE"><span class="hs-identifier hs-type">addUsedGRE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1266"></span><span class="hs-comment">-- Called for both local and imported things</span><span>
</span><span id="line-1267"></span><span class="hs-comment">-- Add usage *and* warn if deprecated</span><span>
</span><span id="line-1268"></span><span id="addUsedGRE"><span class="annot"><span class="annottext">addUsedGRE :: Bool -&gt; GlobalRdrElt -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Env.html#addUsedGRE"><span class="hs-identifier hs-var hs-var">addUsedGRE</span></a></span></span><span> </span><span id="local-6989586621681107426"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107426"><span class="hs-identifier hs-var">warn_if_deprec</span></a></span></span><span> </span><span id="local-6989586621681107425"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107425"><span class="hs-identifier hs-var">gre</span></a></span></span><span>
</span><span id="line-1269"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107426"><span class="hs-identifier hs-var">warn_if_deprec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Env.html#warnIfDeprecated"><span class="hs-identifier hs-var">warnIfDeprecated</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107425"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1270"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#isLocalGRE"><span class="hs-identifier hs-var">isLocalGRE</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107425"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOEnv (Env TcGblEnv TcLclEnv) ()
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) ())
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1271"></span><span>         </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107423"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681107423"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-1272"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;addUsedGRE&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107425"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1273"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">IORef [GlobalRdrElt]
-&gt; ([GlobalRdrElt] -&gt; [GlobalRdrElt])
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall a env. IORef a -&gt; (a -&gt; a) -&gt; IOEnv env ()
</span><a href="GHC.Data.IOEnv.html#updMutVar"><span class="hs-identifier hs-var">updMutVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv -&gt; IORef [GlobalRdrElt]
</span><a href="GHC.Tc.Types.html#tcg_used_gres"><span class="hs-identifier hs-var hs-var">tcg_used_gres</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681107423"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107425"><span class="hs-identifier hs-var">gre</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1274"></span><span>
</span><span id="line-1275"></span><span class="annot"><a href="GHC.Rename.Env.html#addUsedGREs"><span class="hs-identifier hs-type">addUsedGREs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1276"></span><span class="hs-comment">-- Record uses of any *imported* GREs</span><span>
</span><span id="line-1277"></span><span class="hs-comment">-- Used for recording used sub-bndrs</span><span>
</span><span id="line-1278"></span><span class="hs-comment">-- NB: no call to warnIfDeprecated; see Note [Handling of deprecations]</span><span>
</span><span id="line-1279"></span><span id="addUsedGREs"><span class="annot"><span class="annottext">addUsedGREs :: [GlobalRdrElt] -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Env.html#addUsedGREs"><span class="hs-identifier hs-var hs-var">addUsedGREs</span></a></span></span><span> </span><span id="local-6989586621681107420"><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107420"><span class="hs-identifier hs-var">gres</span></a></span></span><span>
</span><span id="line-1280"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107419"><span class="hs-identifier hs-var">imp_gres</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1281"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107418"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681107418"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-1282"></span><span>                       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;addUsedGREs&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107419"><span class="hs-identifier hs-var">imp_gres</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1283"></span><span>                       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">IORef [GlobalRdrElt]
-&gt; ([GlobalRdrElt] -&gt; [GlobalRdrElt])
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall a env. IORef a -&gt; (a -&gt; a) -&gt; IOEnv env ()
</span><a href="GHC.Data.IOEnv.html#updMutVar"><span class="hs-identifier hs-var">updMutVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv -&gt; IORef [GlobalRdrElt]
</span><a href="GHC.Tc.Types.html#tcg_used_gres"><span class="hs-identifier hs-var hs-var">tcg_used_gres</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681107418"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107419"><span class="hs-identifier hs-var">imp_gres</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1284"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1285"></span><span>    </span><span id="local-6989586621681107419"><span class="annot"><span class="annottext">imp_gres :: [GlobalRdrElt]
</span><a href="#local-6989586621681107419"><span class="hs-identifier hs-var hs-var">imp_gres</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Bool) -&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#filterOut"><span class="hs-identifier hs-var">filterOut</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#isLocalGRE"><span class="hs-identifier hs-var">isLocalGRE</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107420"><span class="hs-identifier hs-var">gres</span></a></span><span>
</span><span id="line-1286"></span><span>
</span><span id="line-1287"></span><span class="annot"><a href="GHC.Rename.Env.html#warnIfDeprecated"><span class="hs-identifier hs-type">warnIfDeprecated</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1288"></span><span id="warnIfDeprecated"><span class="annot"><span class="annottext">warnIfDeprecated :: GlobalRdrElt -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Rename.Env.html#warnIfDeprecated"><span class="hs-identifier hs-var hs-var">warnIfDeprecated</span></a></span></span><span> </span><span id="local-6989586621681107416"><span class="annot"><span class="annottext">gre :: GlobalRdrElt
</span><a href="#local-6989586621681107416"><span class="hs-identifier hs-var">gre</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.Reader.html#GRE"><span class="hs-identifier hs-type">GRE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">gre_name :: GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var">gre_name</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681107415"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107415"><span class="hs-identifier hs-var">name</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">gre_imp :: GlobalRdrElt -&gt; [ImportSpec]
</span><a href="GHC.Types.Name.Reader.html#gre_imp"><span class="hs-identifier hs-var">gre_imp</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681107413"><span class="annot"><span class="annottext">[ImportSpec]
</span><a href="#local-6989586621681107413"><span class="hs-identifier hs-var">iss</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1289"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681107412"><span class="annot"><span class="annottext">ImportSpec
</span><a href="#local-6989586621681107412"><span class="hs-identifier hs-var">imp_spec</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span class="annot"><span class="annottext">[ImportSpec]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[ImportSpec]
</span><a href="#local-6989586621681107413"><span class="hs-identifier hs-var">iss</span></a></span><span>
</span><span id="line-1290"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107411"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681107411"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-1291"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681107409"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107409"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-1292"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WarningFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#wopt"><span class="hs-identifier hs-var">wopt</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnWarningsDeprecations"><span class="hs-identifier hs-var">Opt_WarnWarningsDeprecations</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681107411"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-1293"></span><span>               </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module -&gt; Name -&gt; Bool
</span><a href="GHC.Types.Name.html#nameIsLocalOrFrom"><span class="hs-identifier hs-var">nameIsLocalOrFrom</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107409"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107415"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOEnv (Env TcGblEnv TcLclEnv) ()
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) ())
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1294"></span><span>                   </span><span class="hs-comment">-- See Note [Handling of deprecations]</span><span>
</span><span id="line-1295"></span><span>         </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107406"><span class="annot"><span class="annottext">ModIface
</span><a href="#local-6989586621681107406"><span class="hs-identifier hs-var">iface</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Name -&gt; TcRn ModIface
</span><a href="GHC.Iface.Load.html#loadInterfaceForName"><span class="hs-identifier hs-var">loadInterfaceForName</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107405"><span class="hs-identifier hs-var">doc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107415"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-1296"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ModIface -&gt; GlobalRdrElt -&gt; Maybe WarningTxt
</span><a href="GHC.Rename.Env.html#lookupImpDeprec"><span class="hs-identifier hs-var">lookupImpDeprec</span></a></span><span> </span><span class="annot"><span class="annottext">ModIface
</span><a href="#local-6989586621681107406"><span class="hs-identifier hs-var">iface</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107416"><span class="hs-identifier hs-var">gre</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1297"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107403"><span class="annot"><span class="annottext">WarningTxt
</span><a href="#local-6989586621681107403"><span class="hs-identifier hs-var">txt</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">WarnReason -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addWarn"><span class="hs-identifier hs-var">addWarn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WarningFlag -&gt; WarnReason
</span><a href="GHC.Driver.Flags.html#Reason"><span class="hs-identifier hs-var">Reason</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnWarningsDeprecations"><span class="hs-identifier hs-var">Opt_WarnWarningsDeprecations</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1298"></span><span>                                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ImportSpec -&gt; WarningTxt -&gt; MsgDoc
</span><a href="#local-6989586621681107402"><span class="hs-identifier hs-var">mk_msg</span></a></span><span> </span><span class="annot"><span class="annottext">ImportSpec
</span><a href="#local-6989586621681107412"><span class="hs-identifier hs-var">imp_spec</span></a></span><span> </span><span class="annot"><span class="annottext">WarningTxt
</span><a href="#local-6989586621681107403"><span class="hs-identifier hs-var">txt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1299"></span><span>                </span><span class="annot"><span class="annottext">Maybe WarningTxt
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1300"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1301"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1302"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1303"></span><span>    </span><span id="local-6989586621681107401"><span class="annot"><span class="annottext">occ :: OccName
</span><a href="#local-6989586621681107401"><span class="hs-identifier hs-var hs-var">occ</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#greOccName"><span class="hs-identifier hs-var">greOccName</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107416"><span class="hs-identifier hs-var">gre</span></a></span><span>
</span><span id="line-1304"></span><span>    </span><span id="local-6989586621681107395"><span class="annot"><span class="annottext">name_mod :: Module
</span><a href="#local-6989586621681107395"><span class="hs-identifier hs-var hs-var">name_mod</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isExternalName</span><span> </span><span class="hs-identifier">name</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">nameModule</span><span> </span><span class="hs-identifier">name</span><span>
</span><span id="line-1305"></span><span>    </span><span id="local-6989586621681107405"><span class="annot"><span class="annottext">doc :: MsgDoc
</span><a href="#local-6989586621681107405"><span class="hs-identifier hs-var hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;The name&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107401"><span class="hs-identifier hs-var">occ</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PtrString -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ptext"><span class="hs-identifier hs-var">ptext</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; PtrString
</span><a href="GHC.Data.FastString.html#sLit"><span class="hs-identifier hs-var">sLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is mentioned explicitly&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-1306"></span><span>
</span><span id="line-1307"></span><span>    </span><span id="local-6989586621681107402"><span class="annot"><span class="annottext">mk_msg :: ImportSpec -&gt; WarningTxt -&gt; MsgDoc
</span><a href="#local-6989586621681107402"><span class="hs-identifier hs-var hs-var">mk_msg</span></a></span></span><span> </span><span id="local-6989586621681107388"><span class="annot"><span class="annottext">ImportSpec
</span><a href="#local-6989586621681107388"><span class="hs-identifier hs-var">imp_spec</span></a></span></span><span> </span><span id="local-6989586621681107387"><span class="annot"><span class="annottext">WarningTxt
</span><a href="#local-6989586621681107387"><span class="hs-identifier hs-var">txt</span></a></span></span><span>
</span><span id="line-1308"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;In the use of&quot;</span></span><span>
</span><span id="line-1309"></span><span>                    </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">NameSpace -&gt; MsgDoc
</span><a href="GHC.Types.Name.Occurrence.html#pprNonVarNameSpace"><span class="hs-identifier hs-var">pprNonVarNameSpace</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; NameSpace
</span><a href="GHC.Types.Name.Occurrence.html#occNameSpace"><span class="hs-identifier hs-var hs-var">occNameSpace</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107401"><span class="hs-identifier hs-var">occ</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1310"></span><span>                    </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107401"><span class="hs-identifier hs-var">occ</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1311"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107383"><span class="hs-identifier hs-var">imp_msg</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Utils.Outputable.html#colon"><span class="hs-identifier hs-var">colon</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1312"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">WarningTxt -&gt; MsgDoc
</span><a href="GHC.Types.Basic.html#pprWarningTxtForMsg"><span class="hs-identifier hs-var">pprWarningTxtForMsg</span></a></span><span> </span><span class="annot"><span class="annottext">WarningTxt
</span><a href="#local-6989586621681107387"><span class="hs-identifier hs-var">txt</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1313"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1314"></span><span>        </span><span id="local-6989586621681107382"><span class="annot"><span class="annottext">imp_mod :: ModuleName
</span><a href="#local-6989586621681107382"><span class="hs-identifier hs-var hs-var">imp_mod</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImportSpec -&gt; ModuleName
</span><a href="GHC.Types.Name.Reader.html#importSpecModule"><span class="hs-identifier hs-var">importSpecModule</span></a></span><span> </span><span class="annot"><span class="annottext">ImportSpec
</span><a href="#local-6989586621681107388"><span class="hs-identifier hs-var">imp_spec</span></a></span><span>
</span><span id="line-1315"></span><span>        </span><span id="local-6989586621681107383"><span class="annot"><span class="annottext">imp_msg :: MsgDoc
</span><a href="#local-6989586621681107383"><span class="hs-identifier hs-var hs-var">imp_msg</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;imported from&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621681107382"><span class="hs-identifier hs-var">imp_mod</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107378"><span class="hs-identifier hs-var">extra</span></a></span><span>
</span><span id="line-1316"></span><span>        </span><span id="local-6989586621681107378"><span class="annot"><span class="annottext">extra :: MsgDoc
</span><a href="#local-6989586621681107378"><span class="hs-identifier hs-var hs-var">extra</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621681107382"><span class="hs-identifier hs-var">imp_mod</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; ModuleName -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Module -&gt; ModuleName
forall unit. GenModule unit -&gt; ModuleName
</span><a href="GHC.Unit.Types.html#moduleName"><span class="hs-identifier hs-var hs-var">moduleName</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107395"><span class="hs-identifier hs-var">name_mod</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">Outputable.empty</span></a></span><span>
</span><span id="line-1317"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;, but defined in&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Module -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107395"><span class="hs-identifier hs-var">name_mod</span></a></span><span>
</span><span id="line-1318"></span><span>
</span><span id="line-1319"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupImpDeprec"><span class="hs-identifier hs-type">lookupImpDeprec</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#ModIface"><span class="hs-identifier hs-type">ModIface</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#WarningTxt"><span class="hs-identifier hs-type">WarningTxt</span></a></span><span>
</span><span id="line-1320"></span><span id="lookupImpDeprec"><span class="annot"><span class="annottext">lookupImpDeprec :: ModIface -&gt; GlobalRdrElt -&gt; Maybe WarningTxt
</span><a href="GHC.Rename.Env.html#lookupImpDeprec"><span class="hs-identifier hs-var hs-var">lookupImpDeprec</span></a></span></span><span> </span><span id="local-6989586621681107372"><span class="annot"><span class="annottext">ModIface
</span><a href="#local-6989586621681107372"><span class="hs-identifier hs-var">iface</span></a></span></span><span> </span><span id="local-6989586621681107371"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107371"><span class="hs-identifier hs-var">gre</span></a></span></span><span>
</span><span id="line-1321"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ModIfaceBackend -&gt; OccName -&gt; Maybe WarningTxt
</span><a href="GHC.Driver.Types.html#mi_warn_fn"><span class="hs-identifier hs-var hs-var">mi_warn_fn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModIface -&gt; IfaceBackendExts 'ModIfaceFinal
forall (phase :: ModIfacePhase).
ModIface_ phase -&gt; IfaceBackendExts phase
</span><a href="GHC.Driver.Types.html#mi_final_exts"><span class="hs-identifier hs-var hs-var">mi_final_exts</span></a></span><span> </span><span class="annot"><span class="annottext">ModIface
</span><a href="#local-6989586621681107372"><span class="hs-identifier hs-var">iface</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#greOccName"><span class="hs-identifier hs-var">greOccName</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107371"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe WarningTxt -&gt; Maybe WarningTxt -&gt; Maybe WarningTxt
forall (m :: * -&gt; *) a. MonadPlus m =&gt; m a -&gt; m a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#mplus"><span class="hs-operator hs-var">`mplus`</span></a></span><span>  </span><span class="hs-comment">-- Bleat if the thing,</span><span>
</span><span id="line-1322"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Parent
</span><a href="GHC.Types.Name.Reader.html#gre_par"><span class="hs-identifier hs-var hs-var">gre_par</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107371"><span class="hs-identifier hs-var">gre</span></a></span><span> </span><span class="hs-keyword">of</span><span>                      </span><span class="hs-comment">-- or its parent, is warn'd</span><span>
</span><span id="line-1323"></span><span>       </span><span class="annot"><a href="GHC.Types.Name.Reader.html#ParentIs"><span class="hs-identifier hs-type">ParentIs</span></a></span><span>  </span><span id="local-6989586621681107367"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107367"><span class="hs-identifier hs-var">p</span></a></span></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ModIfaceBackend -&gt; OccName -&gt; Maybe WarningTxt
</span><a href="GHC.Driver.Types.html#mi_warn_fn"><span class="hs-identifier hs-var hs-var">mi_warn_fn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModIface -&gt; IfaceBackendExts 'ModIfaceFinal
forall (phase :: ModIfacePhase).
ModIface_ phase -&gt; IfaceBackendExts phase
</span><a href="GHC.Driver.Types.html#mi_final_exts"><span class="hs-identifier hs-var hs-var">mi_final_exts</span></a></span><span> </span><span class="annot"><span class="annottext">ModIface
</span><a href="#local-6989586621681107372"><span class="hs-identifier hs-var">iface</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107367"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1324"></span><span>       </span><span class="annot"><a href="GHC.Types.Name.Reader.html#FldParent"><span class="hs-identifier hs-type">FldParent</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">par_is :: Parent -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#par_is"><span class="hs-identifier hs-var">par_is</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681107366"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107366"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ModIfaceBackend -&gt; OccName -&gt; Maybe WarningTxt
</span><a href="GHC.Driver.Types.html#mi_warn_fn"><span class="hs-identifier hs-var hs-var">mi_warn_fn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModIface -&gt; IfaceBackendExts 'ModIfaceFinal
forall (phase :: ModIfacePhase).
ModIface_ phase -&gt; IfaceBackendExts phase
</span><a href="GHC.Driver.Types.html#mi_final_exts"><span class="hs-identifier hs-var hs-var">mi_final_exts</span></a></span><span> </span><span class="annot"><span class="annottext">ModIface
</span><a href="#local-6989586621681107372"><span class="hs-identifier hs-var">iface</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107366"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1325"></span><span>       </span><span class="annot"><span class="annottext">Parent
</span><a href="GHC.Types.Name.Reader.html#NoParent"><span class="hs-identifier hs-var">NoParent</span></a></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe WarningTxt
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1326"></span><span>
</span><span id="line-1327"></span><span class="hs-comment">{-
Note [Used names with interface not loaded]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's (just) possible to find a used
Name whose interface hasn't been loaded:

a) It might be a WiredInName; in that case we may not load
   its interface (although we could).

b) It might be GHC.Real.fromRational, or GHC.Num.fromInteger
   These are seen as &quot;used&quot; by the renamer (if -XRebindableSyntax)
   is on), but the typechecker may discard their uses
   if in fact the in-scope fromRational is GHC.Read.fromRational,
   (see tcPat.tcOverloadedLit), and the typechecker sees that the type
   is fixed, say, to GHC.Base.Float (see Inst.lookupSimpleInst).
   In that obscure case it won't force the interface in.

In both cases we simply don't permit deprecations;
this is, after all, wired-in stuff.


*********************************************************
*                                                      *
                GHCi support
*                                                      *
*********************************************************

A qualified name on the command line can refer to any module at
all: we try to load the interface if we don't already have it, just
as if there was an &quot;import qualified M&quot; declaration for every
module.

For example, writing `Data.List.sort` will load the interface file for
`Data.List` as if the user had written `import qualified Data.List`.

If we fail we just return Nothing, rather than bleating
about &quot;attempting to use module &#8216;D&#8217; (./D.hs) which is not loaded&quot;
which is what loadSrcInterface does.

It is enabled by default and disabled by the flag
`-fno-implicit-import-qualified`.

Note [Safe Haskell and GHCi]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We DON'T do this Safe Haskell as we need to check imports. We can
and should instead check the qualified import but at the moment
this requires some refactoring so leave as a TODO
-}</span><span>
</span><span id="line-1375"></span><span>
</span><span id="line-1376"></span><span>
</span><span id="line-1377"></span><span>
</span><span id="line-1378"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupQualifiedNameGHCi"><span class="hs-identifier hs-type">lookupQualifiedNameGHCi</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1379"></span><span id="lookupQualifiedNameGHCi"><span class="annot"><span class="annottext">lookupQualifiedNameGHCi :: RdrName -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
</span><a href="GHC.Rename.Env.html#lookupQualifiedNameGHCi"><span class="hs-identifier hs-var hs-var">lookupQualifiedNameGHCi</span></a></span></span><span> </span><span id="local-6989586621681107365"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107365"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-1380"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- We want to behave as we would for a source file import here,</span><span>
</span><span id="line-1381"></span><span>    </span><span class="hs-comment">-- and respect hiddenness of modules/packages, hence loadSrcInterface.</span><span>
</span><span id="line-1382"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107364"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681107364"><span class="hs-identifier hs-var">dflags</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-1383"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681107363"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107363"><span class="hs-identifier hs-var">is_ghci</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Utils.Monad.html#getIsGHCi"><span class="hs-identifier hs-var">getIsGHCi</span></a></span><span>
</span><span id="line-1384"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Bool -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
</span><a href="#local-6989586621681107361"><span class="hs-identifier hs-var">go_for_it</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681107364"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107363"><span class="hs-identifier hs-var">is_ghci</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1385"></span><span>
</span><span id="line-1386"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1387"></span><span>    </span><span id="local-6989586621681107361"><span class="annot"><span class="annottext">go_for_it :: DynFlags -&gt; Bool -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
</span><a href="#local-6989586621681107361"><span class="hs-identifier hs-var hs-var">go_for_it</span></a></span></span><span> </span><span id="local-6989586621681107350"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681107350"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681107349"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107349"><span class="hs-identifier hs-var">is_ghci</span></a></span></span><span>
</span><span id="line-1388"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681107348"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621681107348"><span class="hs-identifier hs-var">mod</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681107347"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107347"><span class="hs-identifier hs-var">occ</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; Maybe (ModuleName, OccName)
</span><a href="GHC.Types.Name.Reader.html#isQual_maybe"><span class="hs-identifier hs-var">isQual_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107365"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1389"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107349"><span class="hs-identifier hs-var">is_ghci</span></a></span><span>
</span><span id="line-1390"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_ImplicitImportQualified"><span class="hs-identifier hs-var">Opt_ImplicitImportQualified</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681107350"><span class="hs-identifier hs-var">dflags</span></a></span><span>   </span><span class="hs-comment">-- Enables this GHCi behaviour</span><span>
</span><span id="line-1391"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#safeDirectImpsReq"><span class="hs-identifier hs-var">safeDirectImpsReq</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681107350"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>            </span><span class="hs-comment">-- See Note [Safe Haskell and GHCi]</span><span>
</span><span id="line-1392"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107342"><span class="annot"><span class="annottext">MaybeErr MsgDoc ModIface
</span><a href="#local-6989586621681107342"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MsgDoc
-&gt; ModuleName
-&gt; IsBootInterface
-&gt; Maybe FieldLabelString
-&gt; RnM (MaybeErr MsgDoc ModIface)
</span><a href="GHC.Iface.Load.html#loadSrcInterface_maybe"><span class="hs-identifier hs-var">loadSrcInterface_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107341"><span class="hs-identifier hs-var">doc</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621681107348"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">IsBootInterface
</span><a href="GHC.Unit.Types.html#NotBoot"><span class="hs-identifier hs-var">NotBoot</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe FieldLabelString
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1393"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MaybeErr MsgDoc ModIface
</span><a href="#local-6989586621681107342"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1394"></span><span>                </span><span class="annot"><a href="GHC.Data.Maybe.html#Succeeded"><span class="hs-identifier hs-type">Succeeded</span></a></span><span> </span><span id="local-6989586621681107338"><span class="annot"><span class="annottext">ModIface
</span><a href="#local-6989586621681107338"><span class="hs-identifier hs-var">iface</span></a></span></span><span>
</span><span id="line-1395"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107337"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-1396"></span><span>                            </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681107336"><span class="annot"><span class="annottext">AvailInfo
</span><a href="#local-6989586621681107336"><span class="hs-identifier hs-var">avail</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ModIface -&gt; [AvailInfo]
forall (phase :: ModIfacePhase). ModIface_ phase -&gt; [AvailInfo]
</span><a href="GHC.Driver.Types.html#mi_exports"><span class="hs-identifier hs-var hs-var">mi_exports</span></a></span><span> </span><span class="annot"><span class="annottext">ModIface
</span><a href="#local-6989586621681107338"><span class="hs-identifier hs-var">iface</span></a></span><span>
</span><span id="line-1397"></span><span>                            </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681107337"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107337"><span class="hs-identifier hs-var">name</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AvailInfo -&gt; [Name]
</span><a href="GHC.Types.Avail.html#availNames"><span class="hs-identifier hs-var">availNames</span></a></span><span> </span><span class="annot"><span class="annottext">AvailInfo
</span><a href="#local-6989586621681107336"><span class="hs-identifier hs-var">avail</span></a></span><span>
</span><span id="line-1398"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107337"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; OccName -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107347"><span class="hs-identifier hs-var">occ</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1399"></span><span>
</span><span id="line-1400"></span><span>                </span><span class="annot"><span class="annottext">MaybeErr MsgDoc ModIface
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-comment">-- Either we couldn't load the interface, or</span><span>
</span><span id="line-1401"></span><span>                     </span><span class="hs-comment">-- we could but we didn't find the name in it</span><span>
</span><span id="line-1402"></span><span>                     </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupQualifiedNameGHCi&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107365"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1403"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1404"></span><span>
</span><span id="line-1405"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1406"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceRn"><span class="hs-identifier hs-var">traceRn</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupQualifiedNameGHCi: off&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107365"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1407"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1408"></span><span>
</span><span id="line-1409"></span><span>    </span><span id="local-6989586621681107341"><span class="annot"><span class="annottext">doc :: MsgDoc
</span><a href="#local-6989586621681107341"><span class="hs-identifier hs-var hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Need to find&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107365"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1410"></span><span>
</span><span id="line-1411"></span><span class="hs-comment">{-
Note [Looking up signature names]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lookupSigOccRn is used for type signatures and pragmas
Is this valid?
  module A
        import M( f )
        f :: Int -&gt; Int
        f x = x
It's clear that the 'f' in the signature must refer to A.f
The Haskell98 report does not stipulate this, but it will!
So we must treat the 'f' in the signature in the same way
as the binding occurrence of 'f', using lookupBndrRn

However, consider this case:
        import M( f )
        f :: Int -&gt; Int
        g x = x
We don't want to say 'f' is out of scope; instead, we want to
return the imported 'f', so that later on the renamer will
correctly report &quot;misplaced type sig&quot;.

Note [Signatures for top level things]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
data HsSigCtxt = ... | TopSigCtxt NameSet | ....

* The NameSet says what is bound in this group of bindings.
  We can't use isLocalGRE from the GlobalRdrEnv, because of this:
       f x = x
       $( ...some TH splice... )
       f :: Int -&gt; Int
  When we encounter the signature for 'f', the binding for 'f'
  will be in the GlobalRdrEnv, and will be a LocalDef. Yet the
  signature is mis-placed

* For type signatures the NameSet should be the names bound by the
  value bindings; for fixity declarations, the NameSet should also
  include class sigs and record selectors

      infix 3 `f`          -- Yes, ok
      f :: C a =&gt; a -&gt; a   -- No, not ok
      class C a where
        f :: a -&gt; a
-}</span><span>
</span><span id="line-1455"></span><span>
</span><span id="line-1456"></span><span class="hs-keyword">data</span><span> </span><span id="HsSigCtxt"><span class="annot"><a href="GHC.Rename.Env.html#HsSigCtxt"><span class="hs-identifier hs-var">HsSigCtxt</span></a></span></span><span>
</span><span id="line-1457"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="TopSigCtxt"><span class="annot"><a href="GHC.Rename.Env.html#TopSigCtxt"><span class="hs-identifier hs-var">TopSigCtxt</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span>       </span><span class="hs-comment">-- At top level, binding these names</span><span>
</span><span id="line-1458"></span><span>                             </span><span class="hs-comment">-- See Note [Signatures for top level things]</span><span>
</span><span id="line-1459"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="LocalBindCtxt"><span class="annot"><a href="GHC.Rename.Env.html#LocalBindCtxt"><span class="hs-identifier hs-var">LocalBindCtxt</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span>    </span><span class="hs-comment">-- In a local binding, binding these names</span><span>
</span><span id="line-1460"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="ClsDeclCtxt"><span class="annot"><a href="GHC.Rename.Env.html#ClsDeclCtxt"><span class="hs-identifier hs-var">ClsDeclCtxt</span></a></span></span><span>   </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>       </span><span class="hs-comment">-- Class decl for this class</span><span>
</span><span id="line-1461"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="InstDeclCtxt"><span class="annot"><a href="GHC.Rename.Env.html#InstDeclCtxt"><span class="hs-identifier hs-var">InstDeclCtxt</span></a></span></span><span>  </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span>    </span><span class="hs-comment">-- Instance decl whose user-written method</span><span>
</span><span id="line-1462"></span><span>                             </span><span class="hs-comment">-- bindings are for these methods</span><span>
</span><span id="line-1463"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="HsBootCtxt"><span class="annot"><a href="GHC.Rename.Env.html#HsBootCtxt"><span class="hs-identifier hs-var">HsBootCtxt</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span>       </span><span class="hs-comment">-- Top level of a hs-boot file, binding these names</span><span>
</span><span id="line-1464"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="RoleAnnotCtxt"><span class="annot"><a href="GHC.Rename.Env.html#RoleAnnotCtxt"><span class="hs-identifier hs-var">RoleAnnotCtxt</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span>    </span><span class="hs-comment">-- A role annotation, with the names of all types</span><span>
</span><span id="line-1465"></span><span>                             </span><span class="hs-comment">-- in the group</span><span>
</span><span id="line-1466"></span><span>
</span><span id="line-1467"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681107324"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#HsSigCtxt"><span class="hs-identifier hs-type">HsSigCtxt</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1468"></span><span>    </span><span id="local-6989586621681107316"><span class="annot"><span class="annottext">ppr :: HsSigCtxt -&gt; MsgDoc
</span><a href="#local-6989586621681107316"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#TopSigCtxt"><span class="hs-identifier hs-type">TopSigCtxt</span></a></span><span> </span><span id="local-6989586621681107315"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107315"><span class="hs-identifier hs-var">ns</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;TopSigCtxt&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107315"><span class="hs-identifier hs-var">ns</span></a></span><span>
</span><span id="line-1469"></span><span>    </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#LocalBindCtxt"><span class="hs-identifier hs-type">LocalBindCtxt</span></a></span><span> </span><span id="local-6989586621681107314"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107314"><span class="hs-identifier hs-var">ns</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;LocalBindCtxt&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107314"><span class="hs-identifier hs-var">ns</span></a></span><span>
</span><span id="line-1470"></span><span>    </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#ClsDeclCtxt"><span class="hs-identifier hs-type">ClsDeclCtxt</span></a></span><span> </span><span id="local-6989586621681107313"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107313"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ClsDeclCtxt&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107313"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1471"></span><span>    </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#InstDeclCtxt"><span class="hs-identifier hs-type">InstDeclCtxt</span></a></span><span> </span><span id="local-6989586621681107312"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107312"><span class="hs-identifier hs-var">ns</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;InstDeclCtxt&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107312"><span class="hs-identifier hs-var">ns</span></a></span><span>
</span><span id="line-1472"></span><span>    </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#HsBootCtxt"><span class="hs-identifier hs-type">HsBootCtxt</span></a></span><span> </span><span id="local-6989586621681107311"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107311"><span class="hs-identifier hs-var">ns</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;HsBootCtxt&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107311"><span class="hs-identifier hs-var">ns</span></a></span><span>
</span><span id="line-1473"></span><span>    </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Rename.Env.html#RoleAnnotCtxt"><span class="hs-identifier hs-type">RoleAnnotCtxt</span></a></span><span> </span><span id="local-6989586621681107310"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107310"><span class="hs-identifier hs-var">ns</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;RoleAnnotCtxt&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107310"><span class="hs-identifier hs-var">ns</span></a></span><span>
</span><span id="line-1474"></span><span>
</span><span id="line-1475"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupSigOccRn"><span class="hs-identifier hs-type">lookupSigOccRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#HsSigCtxt"><span class="hs-identifier hs-type">HsSigCtxt</span></a></span><span>
</span><span id="line-1476"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#Sig"><span class="hs-identifier hs-type">Sig</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcPs"><span class="hs-identifier hs-type">GhcPs</span></a></span><span>
</span><span id="line-1477"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1478"></span><span id="lookupSigOccRn"><span class="annot"><span class="annottext">lookupSigOccRn :: HsSigCtxt -&gt; Sig GhcPs -&gt; Located RdrName -&gt; RnM (Located Name)
</span><a href="GHC.Rename.Env.html#lookupSigOccRn"><span class="hs-identifier hs-var hs-var">lookupSigOccRn</span></a></span></span><span> </span><span id="local-6989586621681107309"><span class="annot"><span class="annottext">HsSigCtxt
</span><a href="#local-6989586621681107309"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681107308"><span class="annot"><span class="annottext">Sig GhcPs
</span><a href="#local-6989586621681107308"><span class="hs-identifier hs-var">sig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsSigCtxt -&gt; MsgDoc -&gt; Located RdrName -&gt; RnM (Located Name)
</span><a href="GHC.Rename.Env.html#lookupSigCtxtOccRn"><span class="hs-identifier hs-var">lookupSigCtxtOccRn</span></a></span><span> </span><span class="annot"><span class="annottext">HsSigCtxt
</span><a href="#local-6989586621681107309"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Sig GhcPs -&gt; MsgDoc
forall name. Sig name -&gt; MsgDoc
</span><a href="GHC.Hs.Binds.html#hsSigDoc"><span class="hs-identifier hs-var">hsSigDoc</span></a></span><span> </span><span class="annot"><span class="annottext">Sig GhcPs
</span><a href="#local-6989586621681107308"><span class="hs-identifier hs-var">sig</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1479"></span><span>
</span><span id="line-1480"></span><span class="hs-comment">-- | Lookup a name in relation to the names in a 'HsSigCtxt'</span><span>
</span><span id="line-1481"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupSigCtxtOccRn"><span class="hs-identifier hs-type">lookupSigCtxtOccRn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#HsSigCtxt"><span class="hs-identifier hs-type">HsSigCtxt</span></a></span><span>
</span><span id="line-1482"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>         </span><span class="hs-comment">-- ^ description of thing we're looking up,</span><span>
</span><span id="line-1483"></span><span>                                   </span><span class="hs-comment">-- like &quot;type family&quot;</span><span>
</span><span id="line-1484"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1485"></span><span id="lookupSigCtxtOccRn"><span class="annot"><span class="annottext">lookupSigCtxtOccRn :: HsSigCtxt -&gt; MsgDoc -&gt; Located RdrName -&gt; RnM (Located Name)
</span><a href="GHC.Rename.Env.html#lookupSigCtxtOccRn"><span class="hs-identifier hs-var hs-var">lookupSigCtxtOccRn</span></a></span></span><span> </span><span id="local-6989586621681107306"><span class="annot"><span class="annottext">HsSigCtxt
</span><a href="#local-6989586621681107306"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681107305"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107305"><span class="hs-identifier hs-var">what</span></a></span></span><span>
</span><span id="line-1486"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(RdrName -&gt; RnM Name) -&gt; Located RdrName -&gt; RnM (Located Name)
forall a b. (a -&gt; TcM b) -&gt; Located a -&gt; TcM (Located b)
</span><a href="GHC.Tc.Utils.Monad.html#wrapLocM"><span class="hs-identifier hs-var">wrapLocM</span></a></span><span> </span><span class="annot"><span class="annottext">((RdrName -&gt; RnM Name) -&gt; Located RdrName -&gt; RnM (Located Name))
-&gt; (RdrName -&gt; RnM Name) -&gt; Located RdrName -&gt; RnM (Located Name)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621681107304"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107304"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1487"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107303"><span class="annot"><span class="annottext">Either MsgDoc Name
</span><a href="#local-6989586621681107303"><span class="hs-identifier hs-var">mb_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HsSigCtxt -&gt; MsgDoc -&gt; RdrName -&gt; RnM (Either MsgDoc Name)
</span><a href="GHC.Rename.Env.html#lookupBindGroupOcc"><span class="hs-identifier hs-var">lookupBindGroupOcc</span></a></span><span> </span><span class="annot"><span class="annottext">HsSigCtxt
</span><a href="#local-6989586621681107306"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107305"><span class="hs-identifier hs-var">what</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107304"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1488"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name
</span><a href="#local-6989586621681107303"><span class="hs-identifier hs-var">mb_name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1489"></span><span>           </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681107301"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107301"><span class="hs-identifier hs-var">err</span></a></span></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107301"><span class="hs-identifier hs-var">err</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; Name
</span><a href="GHC.Rename.Unbound.html#mkUnboundNameRdr"><span class="hs-identifier hs-var">mkUnboundNameRdr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107304"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1490"></span><span>           </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621681107300"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107300"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107300"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1491"></span><span>
</span><span id="line-1492"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupBindGroupOcc"><span class="hs-identifier hs-type">lookupBindGroupOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#HsSigCtxt"><span class="hs-identifier hs-type">HsSigCtxt</span></a></span><span>
</span><span id="line-1493"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-1494"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1495"></span><span class="hs-comment">-- Looks up the RdrName, expecting it to resolve to one of the</span><span>
</span><span id="line-1496"></span><span class="hs-comment">-- bound names passed in.  If not, return an appropriate error message</span><span>
</span><span id="line-1497"></span><span class="hs-comment">--</span><span>
</span><span id="line-1498"></span><span class="hs-comment">-- See Note [Looking up signature names]</span><span>
</span><span id="line-1499"></span><span id="lookupBindGroupOcc"><span class="annot"><span class="annottext">lookupBindGroupOcc :: HsSigCtxt -&gt; MsgDoc -&gt; RdrName -&gt; RnM (Either MsgDoc Name)
</span><a href="GHC.Rename.Env.html#lookupBindGroupOcc"><span class="hs-identifier hs-var hs-var">lookupBindGroupOcc</span></a></span></span><span> </span><span id="local-6989586621681107299"><span class="annot"><span class="annottext">HsSigCtxt
</span><a href="#local-6989586621681107299"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681107298"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107298"><span class="hs-identifier hs-var">what</span></a></span></span><span> </span><span id="local-6989586621681107297"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107297"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-1500"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107296"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107296"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; Maybe Name
</span><a href="GHC.Types.Name.Reader.html#isExact_maybe"><span class="hs-identifier hs-var">isExact_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107297"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1501"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM (Either MsgDoc Name)
</span><a href="GHC.Rename.Env.html#lookupExactOcc_either"><span class="hs-identifier hs-var">lookupExactOcc_either</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107296"><span class="hs-identifier hs-var">n</span></a></span><span>   </span><span class="hs-comment">-- allow for the possibility of missing Exacts;</span><span>
</span><span id="line-1502"></span><span>                              </span><span class="hs-comment">-- see Note [dataTcOccs and Exact Names]</span><span>
</span><span id="line-1503"></span><span>      </span><span class="hs-comment">-- Maybe we should check the side conditions</span><span>
</span><span id="line-1504"></span><span>      </span><span class="hs-comment">-- but it's a pain, and Exact things only show</span><span>
</span><span id="line-1505"></span><span>      </span><span class="hs-comment">-- up when you know what you are doing</span><span>
</span><span id="line-1506"></span><span>
</span><span id="line-1507"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681107295"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107295"><span class="hs-identifier hs-var">rdr_mod</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681107294"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107294"><span class="hs-identifier hs-var">rdr_occ</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; Maybe (Module, OccName)
</span><a href="GHC.Types.Name.Reader.html#isOrig_maybe"><span class="hs-identifier hs-var">isOrig_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107297"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1508"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107293"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107293"><span class="hs-identifier hs-var">n'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Module -&gt; OccName -&gt; RnM Name
forall a b. Module -&gt; OccName -&gt; TcRnIf a b Name
</span><a href="GHC.Iface.Env.html#lookupOrig"><span class="hs-identifier hs-var">lookupOrig</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107295"><span class="hs-identifier hs-var">rdr_mod</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107294"><span class="hs-identifier hs-var">rdr_occ</span></a></span><span>
</span><span id="line-1509"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either MsgDoc Name
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107293"><span class="hs-identifier hs-var">n'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1510"></span><span>
</span><span id="line-1511"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1512"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HsSigCtxt
</span><a href="#local-6989586621681107299"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1513"></span><span>      </span><span class="annot"><a href="GHC.Rename.Env.html#HsBootCtxt"><span class="hs-identifier hs-type">HsBootCtxt</span></a></span><span> </span><span id="local-6989586621681107292"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107292"><span class="hs-identifier hs-var">ns</span></a></span></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Bool) -&gt; RnM (Either MsgDoc Name)
</span><a href="#local-6989586621681107291"><span class="hs-identifier hs-var">lookup_top</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; NameSet -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#elemNameSet"><span class="hs-operator hs-var">`elemNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107292"><span class="hs-identifier hs-var">ns</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1514"></span><span>      </span><span class="annot"><a href="GHC.Rename.Env.html#TopSigCtxt"><span class="hs-identifier hs-type">TopSigCtxt</span></a></span><span> </span><span id="local-6989586621681107290"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107290"><span class="hs-identifier hs-var">ns</span></a></span></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Bool) -&gt; RnM (Either MsgDoc Name)
</span><a href="#local-6989586621681107291"><span class="hs-identifier hs-var">lookup_top</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; NameSet -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#elemNameSet"><span class="hs-operator hs-var">`elemNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107290"><span class="hs-identifier hs-var">ns</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1515"></span><span>      </span><span class="annot"><a href="GHC.Rename.Env.html#RoleAnnotCtxt"><span class="hs-identifier hs-type">RoleAnnotCtxt</span></a></span><span> </span><span id="local-6989586621681107289"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107289"><span class="hs-identifier hs-var">ns</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Bool) -&gt; RnM (Either MsgDoc Name)
</span><a href="#local-6989586621681107291"><span class="hs-identifier hs-var">lookup_top</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; NameSet -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#elemNameSet"><span class="hs-operator hs-var">`elemNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107289"><span class="hs-identifier hs-var">ns</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1516"></span><span>      </span><span class="annot"><a href="GHC.Rename.Env.html#LocalBindCtxt"><span class="hs-identifier hs-type">LocalBindCtxt</span></a></span><span> </span><span id="local-6989586621681107288"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107288"><span class="hs-identifier hs-var">ns</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">NameSet -&gt; RnM (Either MsgDoc Name)
</span><a href="#local-6989586621681107287"><span class="hs-identifier hs-var">lookup_group</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107288"><span class="hs-identifier hs-var">ns</span></a></span><span>
</span><span id="line-1517"></span><span>      </span><span class="annot"><a href="GHC.Rename.Env.html#ClsDeclCtxt"><span class="hs-identifier hs-type">ClsDeclCtxt</span></a></span><span>  </span><span id="local-6989586621681107286"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107286"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM (Either MsgDoc Name)
</span><a href="#local-6989586621681107285"><span class="hs-identifier hs-var">lookup_cls_op</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107286"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-1518"></span><span>      </span><span class="annot"><a href="GHC.Rename.Env.html#InstDeclCtxt"><span class="hs-identifier hs-type">InstDeclCtxt</span></a></span><span> </span><span id="local-6989586621681107284"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107284"><span class="hs-identifier hs-var">ns</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Bool) -&gt; NameSet -&gt; Bool
forall a. (a -&gt; Bool) -&gt; UniqSet a -&gt; Bool
</span><a href="GHC.Types.Unique.Set.html#uniqSetAny"><span class="hs-identifier hs-var">uniqSetAny</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Builtin.Names.html#isUnboundName"><span class="hs-identifier hs-var">isUnboundName</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107284"><span class="hs-identifier hs-var">ns</span></a></span><span> </span><span class="hs-comment">-- #16610</span><span>
</span><span id="line-1519"></span><span>                          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either MsgDoc Name
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Either MsgDoc Name) -&gt; Name -&gt; Either MsgDoc Name
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; Name
</span><a href="GHC.Rename.Unbound.html#mkUnboundNameRdr"><span class="hs-identifier hs-var">mkUnboundNameRdr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107297"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1520"></span><span>                          </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Bool) -&gt; RnM (Either MsgDoc Name)
</span><a href="#local-6989586621681107291"><span class="hs-identifier hs-var">lookup_top</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; NameSet -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#elemNameSet"><span class="hs-operator hs-var">`elemNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107284"><span class="hs-identifier hs-var">ns</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1521"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1522"></span><span>    </span><span id="local-6989586621681107285"><span class="annot"><span class="annottext">lookup_cls_op :: Name -&gt; RnM (Either MsgDoc Name)
</span><a href="#local-6989586621681107285"><span class="hs-identifier hs-var hs-var">lookup_cls_op</span></a></span></span><span> </span><span id="local-6989586621681107283"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107283"><span class="hs-identifier hs-var">cls</span></a></span></span><span>
</span><span id="line-1523"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Name -&gt; MsgDoc -&gt; RdrName -&gt; RnM (Either MsgDoc Name)
</span><a href="GHC.Rename.Env.html#lookupSubBndrOcc"><span class="hs-identifier hs-var">lookupSubBndrOcc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107283"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107282"><span class="hs-identifier hs-var">doc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107297"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1524"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1525"></span><span>        </span><span id="local-6989586621681107282"><span class="annot"><span class="annottext">doc :: MsgDoc
</span><a href="#local-6989586621681107282"><span class="hs-identifier hs-var hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;method of class&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107283"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1526"></span><span>
</span><span id="line-1527"></span><span>    </span><span id="local-6989586621681107291"><span class="annot"><span class="annottext">lookup_top :: (Name -&gt; Bool) -&gt; RnM (Either MsgDoc Name)
</span><a href="#local-6989586621681107291"><span class="hs-identifier hs-var hs-var">lookup_top</span></a></span></span><span> </span><span id="local-6989586621681107275"><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="#local-6989586621681107275"><span class="hs-identifier hs-var">keep_me</span></a></span></span><span>
</span><span id="line-1528"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107274"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107274"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn GlobalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getGlobalRdrEnv"><span class="hs-identifier hs-var">getGlobalRdrEnv</span></a></span><span>
</span><span id="line-1529"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107273"><span class="annot"><span class="annottext">all_gres :: [GlobalRdrElt]
</span><a href="#local-6989586621681107273"><span class="hs-identifier hs-var hs-var">all_gres</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv -&gt; OccName -&gt; [GlobalRdrElt]
</span><a href="GHC.Types.Name.Reader.html#lookupGlobalRdrEnv"><span class="hs-identifier hs-var">lookupGlobalRdrEnv</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107274"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#rdrNameOcc"><span class="hs-identifier hs-var">rdrNameOcc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107297"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1530"></span><span>                 </span><span id="local-6989586621681107272"><span class="annot"><span class="annottext">names_in_scope :: [Name]
</span><a href="#local-6989586621681107272"><span class="hs-identifier hs-var hs-var">names_in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- If rdr_name lacks a binding, only</span><span>
</span><span id="line-1531"></span><span>                                  </span><span class="hs-comment">-- recommend alternatives from related</span><span>
</span><span id="line-1532"></span><span>                                  </span><span class="hs-comment">-- namespaces. See #17593.</span><span>
</span><span id="line-1533"></span><span>                                  </span><span class="annot"><span class="annottext">(Name -&gt; Bool) -&gt; [Name] -&gt; [Name]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681107271"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107271"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">NameSpace -&gt; NameSpace -&gt; Bool
</span><a href="GHC.Types.Name.Occurrence.html#nameSpacesRelated"><span class="hs-identifier hs-var">nameSpacesRelated</span></a></span><span>
</span><span id="line-1534"></span><span>                                                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; NameSpace
</span><a href="GHC.Types.Name.Reader.html#rdrNameSpace"><span class="hs-identifier hs-var">rdrNameSpace</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107297"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1535"></span><span>                                                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; NameSpace
</span><a href="GHC.Types.Name.html#nameNameSpace"><span class="hs-identifier hs-var">nameNameSpace</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107271"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1536"></span><span>                                </span><span class="annot"><span class="annottext">([Name] -&gt; [Name]) -&gt; [Name] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Name) -&gt; [GlobalRdrElt] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span>
</span><span id="line-1537"></span><span>                                </span><span class="annot"><span class="annottext">([GlobalRdrElt] -&gt; [Name]) -&gt; [GlobalRdrElt] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Bool) -&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Bool
</span><a href="GHC.Types.Name.Reader.html#isLocalGRE"><span class="hs-identifier hs-var">isLocalGRE</span></a></span><span>
</span><span id="line-1538"></span><span>                                </span><span class="annot"><span class="annottext">([GlobalRdrElt] -&gt; [GlobalRdrElt])
-&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv -&gt; [GlobalRdrElt]
</span><a href="GHC.Types.Name.Reader.html#globalRdrEnvElts"><span class="hs-identifier hs-var">globalRdrEnvElts</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681107274"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1539"></span><span>                 </span><span id="local-6989586621681107266"><span class="annot"><span class="annottext">candidates_msg :: MsgDoc
</span><a href="#local-6989586621681107266"><span class="hs-identifier hs-var hs-var">candidates_msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; MsgDoc
</span><a href="#local-6989586621681107265"><span class="hs-identifier hs-var">candidates</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107272"><span class="hs-identifier hs-var">names_in_scope</span></a></span><span>
</span><span id="line-1540"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(GlobalRdrElt -&gt; Bool) -&gt; [GlobalRdrElt] -&gt; [GlobalRdrElt]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="#local-6989586621681107275"><span class="hs-identifier hs-var">keep_me</span></a></span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Bool) -&gt; (GlobalRdrElt -&gt; Name) -&gt; GlobalRdrElt -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107273"><span class="hs-identifier hs-var">all_gres</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1541"></span><span>               </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><a href="#local-6989586621681107273"><span class="hs-identifier hs-var">all_gres</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; RnM (Either MsgDoc Name)
forall {m :: * -&gt; *} {b}. Monad m =&gt; MsgDoc -&gt; m (Either MsgDoc b)
</span><a href="#local-6989586621681107264"><span class="hs-identifier hs-var">bale_out_with</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107266"><span class="hs-identifier hs-var">candidates_msg</span></a></span><span>
</span><span id="line-1542"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; RnM (Either MsgDoc Name)
forall {m :: * -&gt; *} {b}. Monad m =&gt; MsgDoc -&gt; m (Either MsgDoc b)
</span><a href="#local-6989586621681107264"><span class="hs-identifier hs-var">bale_out_with</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107263"><span class="hs-identifier hs-var">local_msg</span></a></span><span>
</span><span id="line-1543"></span><span>               </span><span class="hs-special">(</span><span id="local-6989586621681107262"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107262"><span class="hs-identifier hs-var">gre</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[GlobalRdrElt]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either MsgDoc Name
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Name
</span><a href="GHC.Types.Name.Reader.html#gre_name"><span class="hs-identifier hs-var hs-var">gre_name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681107262"><span class="hs-identifier hs-var">gre</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1544"></span><span>
</span><span id="line-1545"></span><span>    </span><span id="local-6989586621681107287"><span class="annot"><span class="annottext">lookup_group :: NameSet -&gt; RnM (Either MsgDoc Name)
</span><a href="#local-6989586621681107287"><span class="hs-identifier hs-var hs-var">lookup_group</span></a></span></span><span> </span><span id="local-6989586621681107256"><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107256"><span class="hs-identifier hs-var">bound_names</span></a></span></span><span>  </span><span class="hs-comment">-- Look in the local envt (not top level)</span><span>
</span><span id="line-1546"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107255"><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107255"><span class="hs-identifier hs-var">mname</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM (Maybe Name)
</span><a href="GHC.Rename.Env.html#lookupLocalOccRn_maybe"><span class="hs-identifier hs-var">lookupLocalOccRn_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107297"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1547"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681107254"><span class="annot"><span class="annottext">LocalRdrEnv
</span><a href="#local-6989586621681107254"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RnM LocalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getLocalRdrEnv"><span class="hs-identifier hs-var">getLocalRdrEnv</span></a></span><span>
</span><span id="line-1548"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681107253"><span class="annot"><span class="annottext">candidates_msg :: MsgDoc
</span><a href="#local-6989586621681107253"><span class="hs-identifier hs-var hs-var">candidates_msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; MsgDoc
</span><a href="#local-6989586621681107265"><span class="hs-identifier hs-var">candidates</span></a></span><span> </span><span class="annot"><span class="annottext">([Name] -&gt; MsgDoc) -&gt; [Name] -&gt; MsgDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LocalRdrEnv -&gt; [Name]
</span><a href="GHC.Types.Name.Reader.html#localRdrEnvElts"><span class="hs-identifier hs-var">localRdrEnvElts</span></a></span><span> </span><span class="annot"><span class="annottext">LocalRdrEnv
</span><a href="#local-6989586621681107254"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-1549"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="#local-6989586621681107255"><span class="hs-identifier hs-var">mname</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1550"></span><span>               </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107251"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107251"><span class="hs-identifier hs-var">n</span></a></span></span><span>
</span><span id="line-1551"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107251"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; NameSet -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#elemNameSet"><span class="hs-operator hs-var">`elemNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681107256"><span class="hs-identifier hs-var">bound_names</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name -&gt; RnM (Either MsgDoc Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Either MsgDoc Name
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107251"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1552"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; RnM (Either MsgDoc Name)
forall {m :: * -&gt; *} {b}. Monad m =&gt; MsgDoc -&gt; m (Either MsgDoc b)
</span><a href="#local-6989586621681107264"><span class="hs-identifier hs-var">bale_out_with</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107263"><span class="hs-identifier hs-var">local_msg</span></a></span><span>
</span><span id="line-1553"></span><span>               </span><span class="annot"><span class="annottext">Maybe Name
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>                         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; RnM (Either MsgDoc Name)
forall {m :: * -&gt; *} {b}. Monad m =&gt; MsgDoc -&gt; m (Either MsgDoc b)
</span><a href="#local-6989586621681107264"><span class="hs-identifier hs-var">bale_out_with</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107253"><span class="hs-identifier hs-var">candidates_msg</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1554"></span><span>
</span><span id="line-1555"></span><span>    </span><span id="local-6989586621681107264"><span class="annot"><span class="annottext">bale_out_with :: MsgDoc -&gt; m (Either MsgDoc b)
</span><a href="#local-6989586621681107264"><span class="hs-identifier hs-var hs-var">bale_out_with</span></a></span></span><span> </span><span id="local-6989586621681107247"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107247"><span class="hs-identifier hs-var">msg</span></a></span></span><span>
</span><span id="line-1556"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc b -&gt; m (Either MsgDoc b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; Either MsgDoc b
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;The&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107298"><span class="hs-identifier hs-var">what</span></a></span><span>
</span><span id="line-1557"></span><span>                                </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;for&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107297"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1558"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Arity -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; MsgDoc) -&gt; MsgDoc -&gt; MsgDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lacks an accompanying binding&quot;</span></span><span class="hs-special">]</span><span>
</span><span id="line-1559"></span><span>                       </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Arity -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107247"><span class="hs-identifier hs-var">msg</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1560"></span><span>
</span><span id="line-1561"></span><span>    </span><span id="local-6989586621681107263"><span class="annot"><span class="annottext">local_msg :: MsgDoc
</span><a href="#local-6989586621681107263"><span class="hs-identifier hs-var hs-var">local_msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; MsgDoc) -&gt; MsgDoc -&gt; MsgDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;The&quot;</span></span><span>  </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107298"><span class="hs-identifier hs-var">what</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PtrString -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ptext"><span class="hs-identifier hs-var">ptext</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; PtrString
</span><a href="GHC.Data.FastString.html#sLit"><span class="hs-identifier hs-var">sLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;must be given where&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-1562"></span><span>                           </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107297"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is declared&quot;</span></span><span>
</span><span id="line-1563"></span><span>
</span><span id="line-1564"></span><span>    </span><span class="hs-comment">-- Identify all similar names and produce a message listing them</span><span>
</span><span id="line-1565"></span><span>    </span><span class="annot"><a href="#local-6989586621681107265"><span class="hs-identifier hs-type">candidates</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span>
</span><span id="line-1566"></span><span>    </span><span id="local-6989586621681107265"><span class="annot"><span class="annottext">candidates :: [Name] -&gt; MsgDoc
</span><a href="#local-6989586621681107265"><span class="hs-identifier hs-var hs-var">candidates</span></a></span></span><span> </span><span id="local-6989586621681107244"><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107244"><span class="hs-identifier hs-var">names_in_scope</span></a></span></span><span>
</span><span id="line-1567"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107243"><span class="hs-identifier hs-var">similar_names</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1568"></span><span>          </span><span class="hs-special">[</span><span class="hs-special">]</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">Outputable.empty</span></a></span><span>
</span><span id="line-1569"></span><span>          </span><span class="hs-special">[</span><span id="local-6989586621681107242"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107242"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Perhaps you meant&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
</span><a href="#local-6989586621681107241"><span class="hs-identifier hs-var">pp_item</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107242"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1570"></span><span>          </span><span class="annot"><span class="annottext">[Name]
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Perhaps you meant one of these:&quot;</span></span><span>
</span><span id="line-1571"></span><span>                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Arity -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Name -&gt; MsgDoc) -&gt; [Name] -&gt; MsgDoc
forall a. (a -&gt; MsgDoc) -&gt; [a] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#pprWithCommas"><span class="hs-identifier hs-var">pprWithCommas</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
</span><a href="#local-6989586621681107241"><span class="hs-identifier hs-var">pp_item</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107243"><span class="hs-identifier hs-var">similar_names</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1572"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1573"></span><span>        </span><span id="local-6989586621681107243"><span class="annot"><span class="annottext">similar_names :: [Name]
</span><a href="#local-6989586621681107243"><span class="hs-identifier hs-var hs-var">similar_names</span></a></span></span><span>
</span><span id="line-1574"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; [(String, Name)] -&gt; [Name]
forall a. String -&gt; [(String, a)] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#fuzzyLookup"><span class="hs-identifier hs-var">fuzzyLookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FieldLabelString -&gt; String
</span><a href="GHC.Data.FastString.html#unpackFS"><span class="hs-identifier hs-var">unpackFS</span></a></span><span> </span><span class="annot"><span class="annottext">(FieldLabelString -&gt; String) -&gt; FieldLabelString -&gt; String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; FieldLabelString
</span><a href="GHC.Types.Name.Occurrence.html#occNameFS"><span class="hs-identifier hs-var hs-var">occNameFS</span></a></span><span> </span><span class="annot"><span class="annottext">(OccName -&gt; FieldLabelString) -&gt; OccName -&gt; FieldLabelString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#rdrNameOcc"><span class="hs-identifier hs-var">rdrNameOcc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107297"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1575"></span><span>                        </span><span class="annot"><span class="annottext">([(String, Name)] -&gt; [Name]) -&gt; [(String, Name)] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Name -&gt; (String, Name)) -&gt; [Name] -&gt; [(String, Name)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681107237"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107237"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">FieldLabelString -&gt; String
</span><a href="GHC.Data.FastString.html#unpackFS"><span class="hs-identifier hs-var">unpackFS</span></a></span><span> </span><span class="annot"><span class="annottext">(FieldLabelString -&gt; String) -&gt; FieldLabelString -&gt; String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; FieldLabelString
</span><a href="GHC.Types.Name.Occurrence.html#occNameFS"><span class="hs-identifier hs-var hs-var">occNameFS</span></a></span><span> </span><span class="annot"><span class="annottext">(OccName -&gt; FieldLabelString) -&gt; OccName -&gt; FieldLabelString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107237"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107237"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1576"></span><span>                              </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107244"><span class="hs-identifier hs-var">names_in_scope</span></a></span><span>
</span><span id="line-1577"></span><span>
</span><span id="line-1578"></span><span>        </span><span id="local-6989586621681107241"><span class="annot"><span class="annottext">pp_item :: Name -&gt; MsgDoc
</span><a href="#local-6989586621681107241"><span class="hs-identifier hs-var hs-var">pp_item</span></a></span></span><span> </span><span id="local-6989586621681107235"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107235"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107235"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
</span><a href="GHC.Types.Name.html#pprDefinedAt"><span class="hs-identifier hs-var">pprDefinedAt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107235"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1579"></span><span>
</span><span id="line-1580"></span><span>
</span><span id="line-1581"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-1582"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupLocalTcNames"><span class="hs-identifier hs-type">lookupLocalTcNames</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Rename.Env.html#HsSigCtxt"><span class="hs-identifier hs-type">HsSigCtxt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-1583"></span><span class="hs-comment">-- GHC extension: look up both the tycon and data con or variable.</span><span>
</span><span id="line-1584"></span><span class="hs-comment">-- Used for top-level fixity signatures and deprecations.</span><span>
</span><span id="line-1585"></span><span class="hs-comment">-- Complain if neither is in scope.</span><span>
</span><span id="line-1586"></span><span class="hs-comment">-- See Note [Fixity signature lookup]</span><span>
</span><span id="line-1587"></span><span id="lookupLocalTcNames"><span class="annot"><span class="annottext">lookupLocalTcNames :: HsSigCtxt -&gt; MsgDoc -&gt; RdrName -&gt; RnM [(RdrName, Name)]
</span><a href="GHC.Rename.Env.html#lookupLocalTcNames"><span class="hs-identifier hs-var hs-var">lookupLocalTcNames</span></a></span></span><span> </span><span id="local-6989586621681107233"><span class="annot"><span class="annottext">HsSigCtxt
</span><a href="#local-6989586621681107233"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681107232"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107232"><span class="hs-identifier hs-var">what</span></a></span></span><span> </span><span id="local-6989586621681107231"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107231"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-1588"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107230"><span class="annot"><span class="annottext">[Either MsgDoc (RdrName, Name)]
</span><a href="#local-6989586621681107230"><span class="hs-identifier hs-var">mb_gres</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(RdrName
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Either MsgDoc (RdrName, Name)))
-&gt; [RdrName]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [Either MsgDoc (RdrName, Name)]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Either MsgDoc (RdrName, Name))
</span><a href="#local-6989586621681107228"><span class="hs-identifier hs-var">lookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; [RdrName]
</span><a href="GHC.Rename.Env.html#dataTcOccs"><span class="hs-identifier hs-var">dataTcOccs</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107231"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1589"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681107227"><span class="annot"><span class="annottext">[MsgDoc]
</span><a href="#local-6989586621681107227"><span class="hs-identifier hs-var">errs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681107226"><span class="annot"><span class="annottext">[(RdrName, Name)]
</span><a href="#local-6989586621681107226"><span class="hs-identifier hs-var">names</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Either MsgDoc (RdrName, Name)] -&gt; ([MsgDoc], [(RdrName, Name)])
forall a b. [Either a b] -&gt; ([a], [b])
</span><a href="../../base/src/Data.Either.html#partitionEithers"><span class="hs-identifier hs-var">partitionEithers</span></a></span><span> </span><span class="annot"><span class="annottext">[Either MsgDoc (RdrName, Name)]
</span><a href="#local-6989586621681107230"><span class="hs-identifier hs-var">mb_gres</span></a></span><span>
</span><span id="line-1590"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(RdrName, Name)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[(RdrName, Name)]
</span><a href="#local-6989586621681107226"><span class="hs-identifier hs-var">names</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IOEnv (Env TcGblEnv TcLclEnv) ()
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) ())
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[MsgDoc]
</span><a href="#local-6989586621681107227"><span class="hs-identifier hs-var">errs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Bleat about one only</span><span>
</span><span id="line-1591"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[(RdrName, Name)] -&gt; RnM [(RdrName, Name)]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">[(RdrName, Name)]
</span><a href="#local-6989586621681107226"><span class="hs-identifier hs-var">names</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1592"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1593"></span><span>    </span><span id="local-6989586621681107228"><span class="annot"><span class="annottext">lookup :: RdrName
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Either MsgDoc (RdrName, Name))
</span><a href="#local-6989586621681107228"><span class="hs-identifier hs-var hs-var">lookup</span></a></span></span><span> </span><span id="local-6989586621681107216"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107216"><span class="hs-identifier hs-var">rdr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107215"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107215"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-1594"></span><span>                    </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681107214"><span class="annot"><span class="annottext">Either MsgDoc Name
</span><a href="#local-6989586621681107214"><span class="hs-identifier hs-var">nameEither</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HsSigCtxt -&gt; MsgDoc -&gt; RdrName -&gt; RnM (Either MsgDoc Name)
</span><a href="GHC.Rename.Env.html#lookupBindGroupOcc"><span class="hs-identifier hs-var">lookupBindGroupOcc</span></a></span><span> </span><span class="annot"><span class="annottext">HsSigCtxt
</span><a href="#local-6989586621681107233"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107232"><span class="hs-identifier hs-var">what</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107216"><span class="hs-identifier hs-var">rdr</span></a></span><span>
</span><span id="line-1595"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Either MsgDoc (RdrName, Name)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Either MsgDoc (RdrName, Name))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module
-&gt; RdrName -&gt; Either MsgDoc Name -&gt; Either MsgDoc (RdrName, Name)
forall {a}.
(HasOccName a, Outputable a) =&gt;
Module -&gt; a -&gt; Either MsgDoc Name -&gt; Either MsgDoc (a, Name)
</span><a href="#local-6989586621681107213"><span class="hs-identifier hs-var">guard_builtin_syntax</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107215"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107216"><span class="hs-identifier hs-var">rdr</span></a></span><span> </span><span class="annot"><span class="annottext">Either MsgDoc Name
</span><a href="#local-6989586621681107214"><span class="hs-identifier hs-var">nameEither</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1596"></span><span>
</span><span id="line-1597"></span><span>    </span><span class="hs-comment">-- Guard against the built-in syntax (ex: `infixl 6 :`), see #15233</span><span>
</span><span id="line-1598"></span><span>    </span><span id="local-6989586621681107213"><span class="annot"><span class="annottext">guard_builtin_syntax :: Module -&gt; a -&gt; Either MsgDoc Name -&gt; Either MsgDoc (a, Name)
</span><a href="#local-6989586621681107213"><span class="hs-identifier hs-var hs-var">guard_builtin_syntax</span></a></span></span><span> </span><span id="local-6989586621681107205"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107205"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span id="local-6989586621681107204"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681107204"><span class="hs-identifier hs-var">rdr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621681107203"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107203"><span class="hs-identifier hs-var">name</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1599"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; Maybe Name
</span><a href="GHC.Builtin.Types.html#isBuiltInOcc_maybe"><span class="hs-identifier hs-var">isBuiltInOcc_maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; OccName
forall name. HasOccName name =&gt; name -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#occName"><span class="hs-identifier hs-var">occName</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681107204"><span class="hs-identifier hs-var">rdr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1600"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681107205"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">Module -&gt; Module -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Name -&gt; Module
Name -&gt; Module
</span><a href="GHC.Types.Name.html#nameModule"><span class="hs-identifier hs-var">nameModule</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107203"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-1601"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Either MsgDoc (a, Name)
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Illegal&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107232"><span class="hs-identifier hs-var">what</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;of built-in syntax:&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681107204"><span class="hs-identifier hs-var">rdr</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1602"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1603"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a, Name) -&gt; Either MsgDoc (a, Name)
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681107204"><span class="hs-identifier hs-var">rdr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107203"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1604"></span><span>    </span><span class="annot"><a href="#local-6989586621681107213"><span class="hs-identifier hs-var">guard_builtin_syntax</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681107199"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107199"><span class="hs-identifier hs-var">err</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Either MsgDoc (a, Name)
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681107199"><span class="hs-identifier hs-var">err</span></a></span><span>
</span><span id="line-1605"></span><span>
</span><span id="line-1606"></span><span class="annot"><a href="GHC.Rename.Env.html#dataTcOccs"><span class="hs-identifier hs-type">dataTcOccs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1607"></span><span class="hs-comment">-- Return both the given name and the same name promoted to the TcClsName</span><span>
</span><span id="line-1608"></span><span class="hs-comment">-- namespace.  This is useful when we aren't sure which we are looking at.</span><span>
</span><span id="line-1609"></span><span class="hs-comment">-- See also Note [dataTcOccs and Exact Names]</span><span>
</span><span id="line-1610"></span><span id="dataTcOccs"><span class="annot"><span class="annottext">dataTcOccs :: RdrName -&gt; [RdrName]
</span><a href="GHC.Rename.Env.html#dataTcOccs"><span class="hs-identifier hs-var hs-var">dataTcOccs</span></a></span></span><span> </span><span id="local-6989586621681107198"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107198"><span class="hs-identifier hs-var">rdr_name</span></a></span></span><span>
</span><span id="line-1611"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; Bool
</span><a href="GHC.Types.Name.Occurrence.html#isDataOcc"><span class="hs-identifier hs-var">isDataOcc</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107196"><span class="hs-identifier hs-var">occ</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; Bool
</span><a href="GHC.Types.Name.Occurrence.html#isVarOcc"><span class="hs-identifier hs-var">isVarOcc</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107196"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-1612"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107198"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107195"><span class="hs-identifier hs-var">rdr_name_tc</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1613"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1614"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107198"><span class="hs-identifier hs-var">rdr_name</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1615"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1616"></span><span>    </span><span id="local-6989586621681107196"><span class="annot"><span class="annottext">occ :: OccName
</span><a href="#local-6989586621681107196"><span class="hs-identifier hs-var hs-var">occ</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#rdrNameOcc"><span class="hs-identifier hs-var">rdrNameOcc</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107198"><span class="hs-identifier hs-var">rdr_name</span></a></span><span>
</span><span id="line-1617"></span><span>    </span><span id="local-6989586621681107195"><span class="annot"><span class="annottext">rdr_name_tc :: RdrName
</span><a href="#local-6989586621681107195"><span class="hs-identifier hs-var hs-var">rdr_name_tc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1618"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107198"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1619"></span><span>        </span><span class="hs-comment">-- The (~) type operator is always in scope, so we need a special case</span><span>
</span><span id="line-1620"></span><span>        </span><span class="hs-comment">-- for it here, or else  :info (~)  fails in GHCi.</span><span>
</span><span id="line-1621"></span><span>        </span><span class="hs-comment">-- See Note [eqTyCon (~) is built-in syntax]</span><span>
</span><span id="line-1622"></span><span>        </span><span class="annot"><a href="GHC.Types.Name.Reader.html#Unqual"><span class="hs-identifier hs-type">Unqual</span></a></span><span> </span><span id="local-6989586621681107192"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107192"><span class="hs-identifier hs-var">occ</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; FieldLabelString
</span><a href="GHC.Types.Name.Occurrence.html#occNameFS"><span class="hs-identifier hs-var hs-var">occNameFS</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107192"><span class="hs-identifier hs-var">occ</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabelString -&gt; FieldLabelString -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; FieldLabelString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;~&quot;</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="GHC.Builtin.Types.html#eqTyCon_RDR"><span class="hs-identifier hs-var">eqTyCon_RDR</span></a></span><span>
</span><span id="line-1623"></span><span>        </span><span class="annot"><span class="annottext">RdrName
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; NameSpace -&gt; RdrName
</span><a href="GHC.Parser.PostProcess.html#setRdrNameSpace"><span class="hs-identifier hs-var">setRdrNameSpace</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107198"><span class="hs-identifier hs-var">rdr_name</span></a></span><span> </span><span class="annot"><span class="annottext">NameSpace
</span><a href="GHC.Types.Name.Occurrence.html#tcName"><span class="hs-identifier hs-var">tcName</span></a></span><span>
</span><span id="line-1624"></span><span>
</span><span id="line-1625"></span><span class="hs-comment">{-
Note [dataTcOccs and Exact Names]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Exact RdrNames can occur in code generated by Template Haskell, and generally
those references are, well, exact. However, the TH `Name` type isn't expressive
enough to always track the correct namespace information, so we sometimes get
the right Unique but wrong namespace. Thus, we still have to do the double-lookup
for Exact RdrNames.

There is also an awkward situation for built-in syntax. Example in GHCi
   :info []
This parses as the Exact RdrName for nilDataCon, but we also want
the list type constructor.

Note that setRdrNameSpace on an Exact name requires the Name to be External,
which it always is for built in syntax.
-}</span><span>
</span><span id="line-1642"></span><span>
</span><span id="line-1643"></span><span>
</span><span id="line-1644"></span><span>
</span><span id="line-1645"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                        Rebindable names
        Dealing with rebindable syntax is driven by the
        Opt_RebindableSyntax dynamic flag.

        In &quot;deriving&quot; code we don't want to use rebindable syntax
        so we switch off the flag locally

*                                                                      *
************************************************************************

Haskell 98 says that when you say &quot;3&quot; you get the &quot;fromInteger&quot; from the
Standard Prelude, regardless of what is in scope.   However, to experiment
with having a language that is less coupled to the standard prelude, we're
trying a non-standard extension that instead gives you whatever &quot;Prelude.fromInteger&quot;
happens to be in scope.  Then you can
        import Prelude ()
        import MyPrelude as Prelude
to get the desired effect.

At the moment this just happens for
  * fromInteger, fromRational on literals (in expressions and patterns)
  * negate (in expressions)
  * minus  (arising from n+k patterns)
  * &quot;do&quot; notation

We store the relevant Name in the HsSyn tree, in
  * HsIntegral/HsFractional/HsIsString
  * NegApp
  * NPlusKPat
  * HsDo
respectively.  Initially, we just store the &quot;standard&quot; name (GHC.Builtin.Names.fromIntegralName,
fromRationalName etc), but the renamer changes this to the appropriate user
name if Opt_NoImplicitPrelude is on.  That is what lookupSyntax does.

We treat the original (standard) names as free-vars too, because the type checker
checks the type of the user thing against the type of the standard thing.
-}</span><span>
</span><span id="line-1685"></span><span>
</span><span id="line-1686"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupIfThenElse"><span class="hs-identifier hs-type">lookupIfThenElse</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>  </span><span class="hs-comment">-- False &lt;=&gt; don't use rebindable syntax under any conditions</span><span>
</span><span id="line-1687"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#SyntaxExpr"><span class="hs-identifier hs-type">SyntaxExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#FreeVars"><span class="hs-identifier hs-type">FreeVars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1688"></span><span class="hs-comment">-- Different to lookupSyntax because in the non-rebindable</span><span>
</span><span id="line-1689"></span><span class="hs-comment">-- case we desugar directly rather than calling an existing function</span><span>
</span><span id="line-1690"></span><span class="hs-comment">-- Hence the (Maybe (SyntaxExpr GhcRn)) return type</span><span>
</span><span id="line-1691"></span><span id="lookupIfThenElse"><span class="annot"><span class="annottext">lookupIfThenElse :: Bool -&gt; RnM (SyntaxExpr GhcRn, NameSet)
</span><a href="GHC.Rename.Env.html#lookupIfThenElse"><span class="hs-identifier hs-var hs-var">lookupIfThenElse</span></a></span></span><span> </span><span id="local-6989586621681107187"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107187"><span class="hs-identifier hs-var">maybe_use_rs</span></a></span></span><span>
</span><span id="line-1692"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107186"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107186"><span class="hs-identifier hs-var">rebindable_on</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#RebindableSyntax"><span class="hs-identifier hs-var">LangExt.RebindableSyntax</span></a></span><span>
</span><span id="line-1693"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107186"><span class="hs-identifier hs-var">rebindable_on</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107187"><span class="hs-identifier hs-var">maybe_use_rs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1694"></span><span>         </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">(SyntaxExprRn, NameSet)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (SyntaxExprRn, NameSet)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SyntaxExprRn
</span><a href="GHC.Hs.Expr.html#NoSyntaxExprRn"><span class="hs-identifier hs-var">NoSyntaxExprRn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="GHC.Types.Name.Set.html#emptyFVs"><span class="hs-identifier hs-var">emptyFVs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1695"></span><span>         </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107182"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107182"><span class="hs-identifier hs-var">ite</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupOccRn"><span class="hs-identifier hs-var">lookupOccRn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FieldLabelString -&gt; RdrName
</span><a href="GHC.Types.Name.Reader.html#mkVarUnqual"><span class="hs-identifier hs-var">mkVarUnqual</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FieldLabelString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ifThenElse&quot;</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1696"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(SyntaxExprRn, NameSet)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (SyntaxExprRn, NameSet)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Name -&gt; SyntaxExprRn
</span><a href="GHC.Hs.Expr.html#mkRnSyntaxExpr"><span class="hs-identifier hs-var">mkRnSyntaxExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107182"><span class="hs-identifier hs-var">ite</span></a></span><span>
</span><span id="line-1697"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; NameSet
</span><a href="GHC.Types.Name.Set.html#unitFV"><span class="hs-identifier hs-var">unitFV</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107182"><span class="hs-identifier hs-var">ite</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1698"></span><span>
</span><span id="line-1699"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupSyntaxName"><span class="hs-identifier hs-type">lookupSyntaxName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>                      </span><span class="hs-comment">-- ^ The standard name</span><span>
</span><span id="line-1700"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#FreeVars"><span class="hs-identifier hs-type">FreeVars</span></a></span><span class="hs-special">)</span><span>      </span><span class="hs-comment">-- ^ Possibly a non-standard name</span><span>
</span><span id="line-1701"></span><span id="lookupSyntaxName"><span class="annot"><span class="annottext">lookupSyntaxName :: Name -&gt; RnM (Name, NameSet)
</span><a href="GHC.Rename.Env.html#lookupSyntaxName"><span class="hs-identifier hs-var hs-var">lookupSyntaxName</span></a></span></span><span> </span><span id="local-6989586621681107178"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107178"><span class="hs-identifier hs-var">std_name</span></a></span></span><span>
</span><span id="line-1702"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107177"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107177"><span class="hs-identifier hs-var">rebindable_on</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#RebindableSyntax"><span class="hs-identifier hs-var">LangExt.RebindableSyntax</span></a></span><span>
</span><span id="line-1703"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107177"><span class="hs-identifier hs-var">rebindable_on</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-1704"></span><span>           </span><span class="annot"><span class="annottext">(Name, NameSet) -&gt; RnM (Name, NameSet)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107178"><span class="hs-identifier hs-var">std_name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="GHC.Types.Name.Set.html#emptyFVs"><span class="hs-identifier hs-var">emptyFVs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1705"></span><span>         </span><span class="hs-keyword">else</span><span>
</span><span id="line-1706"></span><span>            </span><span class="hs-comment">-- Get the similarly named thing from the local environment</span><span>
</span><span id="line-1707"></span><span>           </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107176"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107176"><span class="hs-identifier hs-var">usr_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupOccRn"><span class="hs-identifier hs-var">lookupOccRn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; RdrName
</span><a href="GHC.Types.Name.Reader.html#mkRdrUnqual"><span class="hs-identifier hs-var">mkRdrUnqual</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107178"><span class="hs-identifier hs-var">std_name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1708"></span><span>              </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Name, NameSet) -&gt; RnM (Name, NameSet)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107176"><span class="hs-identifier hs-var">usr_name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; NameSet
</span><a href="GHC.Types.Name.Set.html#unitFV"><span class="hs-identifier hs-var">unitFV</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107176"><span class="hs-identifier hs-var">usr_name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1709"></span><span>
</span><span id="line-1710"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupSyntaxExpr"><span class="hs-identifier hs-type">lookupSyntaxExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>                          </span><span class="hs-comment">-- ^ The standard name</span><span>
</span><span id="line-1711"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#FreeVars"><span class="hs-identifier hs-type">FreeVars</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- ^ Possibly a non-standard name</span><span>
</span><span id="line-1712"></span><span id="lookupSyntaxExpr"><span class="annot"><span class="annottext">lookupSyntaxExpr :: Name -&gt; RnM (HsExpr GhcRn, NameSet)
</span><a href="GHC.Rename.Env.html#lookupSyntaxExpr"><span class="hs-identifier hs-var hs-var">lookupSyntaxExpr</span></a></span></span><span> </span><span id="local-6989586621681107174"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107174"><span class="hs-identifier hs-var">std_name</span></a></span></span><span>
</span><span id="line-1713"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Name, NameSet) -&gt; (HsExpr GhcRn, NameSet))
-&gt; RnM (Name, NameSet) -&gt; RnM (HsExpr GhcRn, NameSet)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Name -&gt; HsExpr GhcRn)
-&gt; (Name, NameSet) -&gt; (HsExpr GhcRn, NameSet)
forall (a :: * -&gt; * -&gt; *) b c d.
Arrow a =&gt;
a b c -&gt; a (b, d) (c, d)
</span><a href="../../base/src/Control.Arrow.html#first"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; HsExpr GhcRn
forall (id :: Pass). IdP (GhcPass id) -&gt; HsExpr (GhcPass id)
</span><a href="GHC.Hs.Utils.html#nl_HsVar"><span class="hs-identifier hs-var">nl_HsVar</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(RnM (Name, NameSet) -&gt; RnM (HsExpr GhcRn, NameSet))
-&gt; RnM (Name, NameSet) -&gt; RnM (HsExpr GhcRn, NameSet)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM (Name, NameSet)
</span><a href="GHC.Rename.Env.html#lookupSyntaxName"><span class="hs-identifier hs-var">lookupSyntaxName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107174"><span class="hs-identifier hs-var">std_name</span></a></span><span>
</span><span id="line-1714"></span><span>
</span><span id="line-1715"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupSyntax"><span class="hs-identifier hs-type">lookupSyntax</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>                             </span><span class="hs-comment">-- The standard name</span><span>
</span><span id="line-1716"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#SyntaxExpr"><span class="hs-identifier hs-type">SyntaxExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#FreeVars"><span class="hs-identifier hs-type">FreeVars</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Possibly a non-standard</span><span>
</span><span id="line-1717"></span><span>                                                 </span><span class="hs-comment">-- name</span><span>
</span><span id="line-1718"></span><span id="lookupSyntax"><span class="annot"><span class="annottext">lookupSyntax :: Name -&gt; RnM (SyntaxExpr GhcRn, NameSet)
</span><a href="GHC.Rename.Env.html#lookupSyntax"><span class="hs-identifier hs-var hs-var">lookupSyntax</span></a></span></span><span> </span><span id="local-6989586621681107172"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107172"><span class="hs-identifier hs-var">std_name</span></a></span></span><span>
</span><span id="line-1719"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((HsExpr GhcRn, NameSet) -&gt; (SyntaxExprRn, NameSet))
-&gt; RnM (HsExpr GhcRn, NameSet)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (SyntaxExprRn, NameSet)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(HsExpr GhcRn -&gt; SyntaxExprRn)
-&gt; (HsExpr GhcRn, NameSet) -&gt; (SyntaxExprRn, NameSet)
forall (a :: * -&gt; * -&gt; *) b c d.
Arrow a =&gt;
a b c -&gt; a (b, d) (c, d)
</span><a href="../../base/src/Control.Arrow.html#first"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcRn -&gt; SyntaxExprRn
</span><a href="GHC.Hs.Expr.html#mkSyntaxExpr"><span class="hs-identifier hs-var">mkSyntaxExpr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(RnM (HsExpr GhcRn, NameSet)
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (SyntaxExprRn, NameSet))
-&gt; RnM (HsExpr GhcRn, NameSet)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (SyntaxExprRn, NameSet)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM (HsExpr GhcRn, NameSet)
</span><a href="GHC.Rename.Env.html#lookupSyntaxExpr"><span class="hs-identifier hs-var">lookupSyntaxExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107172"><span class="hs-identifier hs-var">std_name</span></a></span><span>
</span><span id="line-1720"></span><span>
</span><span id="line-1721"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupSyntaxNames"><span class="hs-identifier hs-type">lookupSyntaxNames</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span>                         </span><span class="hs-comment">-- Standard names</span><span>
</span><span id="line-1722"></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#FreeVars"><span class="hs-identifier hs-type">FreeVars</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- See comments with HsExpr.ReboundNames</span><span>
</span><span id="line-1723"></span><span>   </span><span class="hs-comment">-- this works with CmdTop, which wants HsExprs, not SyntaxExprs</span><span>
</span><span id="line-1724"></span><span id="lookupSyntaxNames"><span class="annot"><span class="annottext">lookupSyntaxNames :: [Name] -&gt; RnM ([HsExpr GhcRn], NameSet)
</span><a href="GHC.Rename.Env.html#lookupSyntaxNames"><span class="hs-identifier hs-var hs-var">lookupSyntaxNames</span></a></span></span><span> </span><span id="local-6989586621681107170"><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107170"><span class="hs-identifier hs-var">std_names</span></a></span></span><span>
</span><span id="line-1725"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107169"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107169"><span class="hs-identifier hs-var">rebindable_on</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#RebindableSyntax"><span class="hs-identifier hs-var">LangExt.RebindableSyntax</span></a></span><span>
</span><span id="line-1726"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107169"><span class="hs-identifier hs-var">rebindable_on</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-1727"></span><span>             </span><span class="annot"><span class="annottext">([HsExpr GhcRn], NameSet) -&gt; RnM ([HsExpr GhcRn], NameSet)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Name -&gt; HsExpr GhcRn) -&gt; [Name] -&gt; [HsExpr GhcRn]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XVar GhcRn -&gt; Located (IdP GhcRn) -&gt; HsExpr GhcRn
forall p. XVar p -&gt; Located (IdP p) -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsVar"><span class="hs-identifier hs-var">HsVar</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XVar GhcRn
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="annot"><span class="annottext">(Located Name -&gt; HsExpr GhcRn)
-&gt; (Name -&gt; Located Name) -&gt; Name -&gt; HsExpr GhcRn
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Located Name
forall e. e -&gt; Located e
</span><a href="GHC.Types.SrcLoc.html#noLoc"><span class="hs-identifier hs-var">noLoc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107170"><span class="hs-identifier hs-var">std_names</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="GHC.Types.Name.Set.html#emptyFVs"><span class="hs-identifier hs-var">emptyFVs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1728"></span><span>        </span><span class="hs-keyword">else</span><span>
</span><span id="line-1729"></span><span>          </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107165"><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107165"><span class="hs-identifier hs-var">usr_names</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; RnM Name)
-&gt; [Name] -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Name]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupOccRn"><span class="hs-identifier hs-var">lookupOccRn</span></a></span><span> </span><span class="annot"><span class="annottext">(RdrName -&gt; RnM Name) -&gt; (Name -&gt; RdrName) -&gt; Name -&gt; RnM Name
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; RdrName
</span><a href="GHC.Types.Name.Reader.html#mkRdrUnqual"><span class="hs-identifier hs-var">mkRdrUnqual</span></a></span><span> </span><span class="annot"><span class="annottext">(OccName -&gt; RdrName) -&gt; (Name -&gt; OccName) -&gt; Name -&gt; RdrName
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107170"><span class="hs-identifier hs-var">std_names</span></a></span><span>
</span><span id="line-1730"></span><span>             </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([HsExpr GhcRn], NameSet) -&gt; RnM ([HsExpr GhcRn], NameSet)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Name -&gt; HsExpr GhcRn) -&gt; [Name] -&gt; [HsExpr GhcRn]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XVar GhcRn -&gt; Located (IdP GhcRn) -&gt; HsExpr GhcRn
forall p. XVar p -&gt; Located (IdP p) -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsVar"><span class="hs-identifier hs-var">HsVar</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XVar GhcRn
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="annot"><span class="annottext">(Located Name -&gt; HsExpr GhcRn)
-&gt; (Name -&gt; Located Name) -&gt; Name -&gt; HsExpr GhcRn
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Located Name
forall e. e -&gt; Located e
</span><a href="GHC.Types.SrcLoc.html#noLoc"><span class="hs-identifier hs-var">noLoc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107165"><span class="hs-identifier hs-var">usr_names</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; NameSet
</span><a href="GHC.Types.Name.Set.html#mkFVs"><span class="hs-identifier hs-var">mkFVs</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681107165"><span class="hs-identifier hs-var">usr_names</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1731"></span><span>
</span><span id="line-1732"></span><span class="hs-comment">{-
Note [QualifiedDo]
~~~~~~~~~~~~~~~~~~
QualifiedDo is implemented using the same placeholders for operation names in
the AST that were devised for RebindableSyntax. Whenever the renamer checks
which names to use for do syntax, it first checks if the do block is qualified
(e.g. M.do { stmts }), in which case it searches for qualified names. If the
qualified names are not in scope, an error is produced. If the do block is not
qualified, the renamer does the usual search of the names which considers
whether RebindableSyntax is enabled or not. Dealing with QualifiedDo is driven
by the Opt_QualifiedDo dynamic flag.
-}</span><span>
</span><span id="line-1744"></span><span>
</span><span id="line-1745"></span><span class="hs-comment">-- Lookup operations for a qualified do. If the context is not a qualified</span><span>
</span><span id="line-1746"></span><span class="hs-comment">-- do, then use lookupSyntaxExpr. See Note [QualifiedDo].</span><span>
</span><span id="line-1747"></span><span id="local-6989586621681108242"><span class="annot"><a href="GHC.Rename.Env.html#lookupQualifiedDoExpr"><span class="hs-identifier hs-type">lookupQualifiedDoExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsStmtContext"><span class="hs-identifier hs-type">HsStmtContext</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681108242"><span class="hs-identifier hs-type">p</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#FreeVars"><span class="hs-identifier hs-type">FreeVars</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-1748"></span><span id="lookupQualifiedDoExpr"><span class="annot"><span class="annottext">lookupQualifiedDoExpr :: forall p. HsStmtContext p -&gt; Name -&gt; RnM (HsExpr GhcRn, NameSet)
</span><a href="GHC.Rename.Env.html#lookupQualifiedDoExpr"><span class="hs-identifier hs-var hs-var">lookupQualifiedDoExpr</span></a></span></span><span> </span><span id="local-6989586621681107161"><span class="annot"><span class="annottext">HsStmtContext p
</span><a href="#local-6989586621681107161"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681107160"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107160"><span class="hs-identifier hs-var">std_name</span></a></span></span><span>
</span><span id="line-1749"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; HsExpr GhcRn)
-&gt; (Name, NameSet) -&gt; (HsExpr GhcRn, NameSet)
forall (a :: * -&gt; * -&gt; *) b c d.
Arrow a =&gt;
a b c -&gt; a (b, d) (c, d)
</span><a href="../../base/src/Control.Arrow.html#first"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; HsExpr GhcRn
forall (id :: Pass). IdP (GhcPass id) -&gt; HsExpr (GhcPass id)
</span><a href="GHC.Hs.Utils.html#nl_HsVar"><span class="hs-identifier hs-var">nl_HsVar</span></a></span><span> </span><span class="annot"><span class="annottext">((Name, NameSet) -&gt; (HsExpr GhcRn, NameSet))
-&gt; RnM (Name, NameSet) -&gt; RnM (HsExpr GhcRn, NameSet)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HsStmtContext p -&gt; Name -&gt; RnM (Name, NameSet)
forall p. HsStmtContext p -&gt; Name -&gt; RnM (Name, NameSet)
</span><a href="GHC.Rename.Env.html#lookupQualifiedDoName"><span class="hs-identifier hs-var">lookupQualifiedDoName</span></a></span><span> </span><span class="annot"><span class="annottext">HsStmtContext p
</span><a href="#local-6989586621681107161"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107160"><span class="hs-identifier hs-var">std_name</span></a></span><span>
</span><span id="line-1750"></span><span>
</span><span id="line-1751"></span><span class="hs-comment">-- Like lookupQualifiedDoExpr but for producing SyntaxExpr.</span><span>
</span><span id="line-1752"></span><span class="hs-comment">-- See Note [QualifiedDo].</span><span>
</span><span id="line-1753"></span><span id="local-6989586621681108238"><span class="annot"><a href="GHC.Rename.Env.html#lookupQualifiedDo"><span class="hs-identifier hs-type">lookupQualifiedDo</span></a></span><span>
</span><span id="line-1754"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsStmtContext"><span class="hs-identifier hs-type">HsStmtContext</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681108238"><span class="hs-identifier hs-type">p</span></a></span><span>
</span><span id="line-1755"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-1756"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#SyntaxExpr"><span class="hs-identifier hs-type">SyntaxExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#FreeVars"><span class="hs-identifier hs-type">FreeVars</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-1757"></span><span id="lookupQualifiedDo"><span class="annot"><span class="annottext">lookupQualifiedDo :: forall p.
HsStmtContext p -&gt; Name -&gt; RnM (SyntaxExpr GhcRn, NameSet)
</span><a href="GHC.Rename.Env.html#lookupQualifiedDo"><span class="hs-identifier hs-var hs-var">lookupQualifiedDo</span></a></span></span><span> </span><span id="local-6989586621681107157"><span class="annot"><span class="annottext">HsStmtContext p
</span><a href="#local-6989586621681107157"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681107156"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107156"><span class="hs-identifier hs-var">std_name</span></a></span></span><span>
</span><span id="line-1758"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(HsExpr GhcRn -&gt; SyntaxExprRn)
-&gt; (HsExpr GhcRn, NameSet) -&gt; (SyntaxExprRn, NameSet)
forall (a :: * -&gt; * -&gt; *) b c d.
Arrow a =&gt;
a b c -&gt; a (b, d) (c, d)
</span><a href="../../base/src/Control.Arrow.html#first"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcRn -&gt; SyntaxExprRn
</span><a href="GHC.Hs.Expr.html#mkSyntaxExpr"><span class="hs-identifier hs-var">mkSyntaxExpr</span></a></span><span> </span><span class="annot"><span class="annottext">((HsExpr GhcRn, NameSet) -&gt; (SyntaxExprRn, NameSet))
-&gt; RnM (HsExpr GhcRn, NameSet)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (SyntaxExprRn, NameSet)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HsStmtContext p -&gt; Name -&gt; RnM (HsExpr GhcRn, NameSet)
forall p. HsStmtContext p -&gt; Name -&gt; RnM (HsExpr GhcRn, NameSet)
</span><a href="GHC.Rename.Env.html#lookupQualifiedDoExpr"><span class="hs-identifier hs-var">lookupQualifiedDoExpr</span></a></span><span> </span><span class="annot"><span class="annottext">HsStmtContext p
</span><a href="#local-6989586621681107157"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107156"><span class="hs-identifier hs-var">std_name</span></a></span><span>
</span><span id="line-1759"></span><span>
</span><span id="line-1760"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupNameWithQualifier"><span class="hs-identifier hs-type">lookupNameWithQualifier</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Unit.Module.Name.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#FreeVars"><span class="hs-identifier hs-type">FreeVars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1761"></span><span id="lookupNameWithQualifier"><span class="annot"><span class="annottext">lookupNameWithQualifier :: Name -&gt; ModuleName -&gt; RnM (Name, NameSet)
</span><a href="GHC.Rename.Env.html#lookupNameWithQualifier"><span class="hs-identifier hs-var hs-var">lookupNameWithQualifier</span></a></span></span><span> </span><span id="local-6989586621681107155"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107155"><span class="hs-identifier hs-var">std_name</span></a></span></span><span> </span><span id="local-6989586621681107154"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621681107154"><span class="hs-identifier hs-var">modName</span></a></span></span><span>
</span><span id="line-1762"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681107153"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107153"><span class="hs-identifier hs-var">qname</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupOccRn"><span class="hs-identifier hs-var">lookupOccRn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName -&gt; OccName -&gt; RdrName
</span><a href="GHC.Types.Name.Reader.html#mkRdrQual"><span class="hs-identifier hs-var">mkRdrQual</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621681107154"><span class="hs-identifier hs-var">modName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107155"><span class="hs-identifier hs-var">std_name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1763"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Name, NameSet) -&gt; RnM (Name, NameSet)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107153"><span class="hs-identifier hs-var">qname</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; NameSet
</span><a href="GHC.Types.Name.Set.html#unitFV"><span class="hs-identifier hs-var">unitFV</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107153"><span class="hs-identifier hs-var">qname</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1764"></span><span>
</span><span id="line-1765"></span><span class="hs-comment">-- See Note [QualifiedDo].</span><span>
</span><span id="line-1766"></span><span id="local-6989586621681108239"><span class="annot"><a href="GHC.Rename.Env.html#lookupQualifiedDoName"><span class="hs-identifier hs-type">lookupQualifiedDoName</span></a></span><span>
</span><span id="line-1767"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsStmtContext"><span class="hs-identifier hs-type">HsStmtContext</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681108239"><span class="hs-identifier hs-type">p</span></a></span><span>
</span><span id="line-1768"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-1769"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#FreeVars"><span class="hs-identifier hs-type">FreeVars</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-1770"></span><span id="lookupQualifiedDoName"><span class="annot"><span class="annottext">lookupQualifiedDoName :: forall p. HsStmtContext p -&gt; Name -&gt; RnM (Name, NameSet)
</span><a href="GHC.Rename.Env.html#lookupQualifiedDoName"><span class="hs-identifier hs-var hs-var">lookupQualifiedDoName</span></a></span></span><span> </span><span id="local-6989586621681107151"><span class="annot"><span class="annottext">HsStmtContext p
</span><a href="#local-6989586621681107151"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681107150"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107150"><span class="hs-identifier hs-var">std_name</span></a></span></span><span>
</span><span id="line-1771"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HsStmtContext p -&gt; Maybe ModuleName
forall p. HsStmtContext p -&gt; Maybe ModuleName
</span><a href="GHC.Hs.Expr.html#qualifiedDoModuleName_maybe"><span class="hs-identifier hs-var">qualifiedDoModuleName_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">HsStmtContext p
</span><a href="#local-6989586621681107151"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1772"></span><span>      </span><span class="annot"><span class="annottext">Maybe ModuleName
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; RnM (Name, NameSet)
</span><a href="GHC.Rename.Env.html#lookupSyntaxName"><span class="hs-identifier hs-var">lookupSyntaxName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107150"><span class="hs-identifier hs-var">std_name</span></a></span><span>
</span><span id="line-1773"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681107148"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621681107148"><span class="hs-identifier hs-var">modName</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; ModuleName -&gt; RnM (Name, NameSet)
</span><a href="GHC.Rename.Env.html#lookupNameWithQualifier"><span class="hs-identifier hs-var">lookupNameWithQualifier</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107150"><span class="hs-identifier hs-var">std_name</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621681107148"><span class="hs-identifier hs-var">modName</span></a></span><span>
</span><span id="line-1774"></span><span>
</span><span id="line-1775"></span><span>
</span><span id="line-1776"></span><span class="hs-comment">-- Lookup a locally-rebound name for Rebindable Syntax (RS).</span><span>
</span><span id="line-1777"></span><span class="hs-comment">--</span><span>
</span><span id="line-1778"></span><span class="hs-comment">-- - When RS is off, 'lookupRebound' just returns 'Nothing', whatever</span><span>
</span><span id="line-1779"></span><span class="hs-comment">--   name it is given.</span><span>
</span><span id="line-1780"></span><span class="hs-comment">--</span><span>
</span><span id="line-1781"></span><span class="hs-comment">-- - When RS is on, we always try to return a 'Just', and GHC errors out</span><span>
</span><span id="line-1782"></span><span class="hs-comment">--   if no suitable name is found in the environment.</span><span>
</span><span id="line-1783"></span><span class="hs-comment">--</span><span>
</span><span id="line-1784"></span><span class="hs-comment">-- 'Nothing' really is &quot;reserved&quot; and means that rebindable syntax is off.</span><span>
</span><span id="line-1785"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupRebound"><span class="hs-identifier hs-type">lookupRebound</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1786"></span><span id="lookupRebound"><span class="annot"><span class="annottext">lookupRebound :: FieldLabelString -&gt; RnM (Maybe (Located Name))
</span><a href="GHC.Rename.Env.html#lookupRebound"><span class="hs-identifier hs-var hs-var">lookupRebound</span></a></span></span><span> </span><span id="local-6989586621681107146"><span class="annot"><span class="annottext">FieldLabelString
</span><a href="#local-6989586621681107146"><span class="hs-identifier hs-var">nameStr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1787"></span><span>  </span><span id="local-6989586621681107145"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107145"><span class="hs-identifier hs-var">rebind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#RebindableSyntax"><span class="hs-identifier hs-var">LangExt.RebindableSyntax</span></a></span><span>
</span><span id="line-1788"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681107145"><span class="hs-identifier hs-var">rebind</span></a></span><span>
</span><span id="line-1789"></span><span>    </span><span class="hs-comment">-- If repetitive lookups ever become a problem perormance-wise,</span><span>
</span><span id="line-1790"></span><span>    </span><span class="hs-comment">-- we could lookup all the names we will ever care about just once</span><span>
</span><span id="line-1791"></span><span>    </span><span class="hs-comment">-- at the beginning and stick them in the environment, possibly</span><span>
</span><span id="line-1792"></span><span>    </span><span class="hs-comment">-- populating that &quot;cache&quot; lazily too.</span><span>
</span><span id="line-1793"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681107144"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107144"><span class="hs-identifier hs-var">nm</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Located Name -&gt; Maybe (Located Name)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; Name -&gt; Located Name
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#nameSrcSpan"><span class="hs-identifier hs-var">nameSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107144"><span class="hs-identifier hs-var">nm</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681107144"><span class="hs-identifier hs-var">nm</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Maybe (Located Name))
-&gt; RnM Name -&gt; RnM (Maybe (Located Name))
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span>
</span><span id="line-1794"></span><span>         </span><span class="annot"><span class="annottext">RdrName -&gt; RnM Name
</span><a href="GHC.Rename.Env.html#lookupOccRn"><span class="hs-identifier hs-var">lookupOccRn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FieldLabelString -&gt; RdrName
</span><a href="GHC.Types.Name.Reader.html#mkVarUnqual"><span class="hs-identifier hs-var">mkVarUnqual</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabelString
</span><a href="#local-6989586621681107146"><span class="hs-identifier hs-var">nameStr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1795"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Maybe (Located Name) -&gt; RnM (Maybe (Located Name))
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Located Name)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1796"></span><span>
</span><span id="line-1797"></span><span class="hs-comment">-- | Lookup an @ifThenElse@ binding (see 'lookupRebound').</span><span>
</span><span id="line-1798"></span><span class="annot"><a href="GHC.Rename.Env.html#lookupReboundIf"><span class="hs-identifier hs-type">lookupReboundIf</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#RnM"><span class="hs-identifier hs-type">RnM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1799"></span><span id="lookupReboundIf"><span class="annot"><span class="annottext">lookupReboundIf :: RnM (Maybe (Located Name))
</span><a href="GHC.Rename.Env.html#lookupReboundIf"><span class="hs-identifier hs-var hs-var">lookupReboundIf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FieldLabelString -&gt; RnM (Maybe (Located Name))
</span><a href="GHC.Rename.Env.html#lookupRebound"><span class="hs-identifier hs-var">lookupRebound</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLabelString
</span><a href="GHC.Builtin.RebindableNames.html#reboundIfSymbol"><span class="hs-identifier hs-var">reboundIfSymbol</span></a></span><span>
</span><span id="line-1800"></span><span>
</span><span id="line-1801"></span><span class="hs-comment">-- Error messages</span><span>
</span><span id="line-1802"></span><span>
</span><span id="line-1803"></span><span>
</span><span id="line-1804"></span><span class="annot"><a href="GHC.Rename.Env.html#opDeclErr"><span class="hs-identifier hs-type">opDeclErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-1805"></span><span id="opDeclErr"><span class="annot"><span class="annottext">opDeclErr :: RdrName -&gt; MsgDoc
</span><a href="GHC.Rename.Env.html#opDeclErr"><span class="hs-identifier hs-var hs-var">opDeclErr</span></a></span></span><span> </span><span id="local-6989586621681107142"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107142"><span class="hs-identifier hs-var">n</span></a></span></span><span>
</span><span id="line-1806"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Arity -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Illegal declaration of a type or class operator&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107142"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1807"></span><span>       </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Use TypeOperators to declare operators in type and declarations&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-1808"></span><span>
</span><span id="line-1809"></span><span class="annot"><a href="GHC.Rename.Env.html#badOrigBinding"><span class="hs-identifier hs-type">badOrigBinding</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#RdrName"><span class="hs-identifier hs-type">RdrName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-1810"></span><span id="badOrigBinding"><span class="annot"><span class="annottext">badOrigBinding :: RdrName -&gt; MsgDoc
</span><a href="GHC.Rename.Env.html#badOrigBinding"><span class="hs-identifier hs-var hs-var">badOrigBinding</span></a></span></span><span> </span><span id="local-6989586621681107141"><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107141"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-1811"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; Maybe Name
</span><a href="GHC.Builtin.Types.html#isBuiltInOcc_maybe"><span class="hs-identifier hs-var">isBuiltInOcc_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107140"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-1812"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Illegal binding of built-in syntax:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681107140"><span class="hs-identifier hs-var">occ</span></a></span><span>
</span><span id="line-1813"></span><span>    </span><span class="hs-comment">-- Use an OccName here because we don't want to print Prelude.(,)</span><span>
</span><span id="line-1814"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1815"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Cannot redefine a Name retrieved by a Template Haskell quote:&quot;</span></span><span>
</span><span id="line-1816"></span><span>    </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107141"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-1817"></span><span>    </span><span class="hs-comment">-- This can happen when one tries to use a Template Haskell splice to</span><span>
</span><span id="line-1818"></span><span>    </span><span class="hs-comment">-- define a top-level identifier with an already existing name, e.g.,</span><span>
</span><span id="line-1819"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-1820"></span><span>    </span><span class="hs-comment">--   $(pure [ValD (VarP 'succ) (NormalB (ConE 'True)) []])</span><span>
</span><span id="line-1821"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-1822"></span><span>    </span><span class="hs-comment">-- (See #13968.)</span><span>
</span><span id="line-1823"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1824"></span><span>    </span><span id="local-6989586621681107140"><span class="annot"><span class="annottext">occ :: OccName
</span><a href="#local-6989586621681107140"><span class="hs-identifier hs-var hs-var">occ</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; OccName
</span><a href="GHC.Types.Name.Reader.html#rdrNameOcc"><span class="hs-identifier hs-var">rdrNameOcc</span></a></span><span> </span><span class="annot"><span class="annottext">(RdrName -&gt; OccName) -&gt; RdrName -&gt; OccName
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName -&gt; RdrName
</span><a href="GHC.Parser.PostProcess.html#filterCTuple"><span class="hs-identifier hs-var">filterCTuple</span></a></span><span> </span><span class="annot"><span class="annottext">RdrName
</span><a href="#local-6989586621681107141"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-1825"></span></pre></body></html>